cancel
Showing results for 
Search instead for 
Did you mean: 

Get Current date on click of Preview button on opportunity

dhruv_mehta
Active Contributor
0 Kudos

Dear All,

We want to show the user current date on Opportunity Summary form when he clicks on "Preview Button"

Is there anyway I can do that?

I tried creating a Transient field but i am stuck on where to code it. since Root - aftermodify will not get triggered.

Kindly suggest.

Regards, Dhruvin

Accepted Solutions (1)

Accepted Solutions (1)

Hi Dhruvin,

You can follow below steps to display current date on Preview of Opportunity Summary:

1) drag and drop date field

2) In Properties window select Type as Calculated-Read Only

3) Then select Current Date in Runtime Property.

Save the form and try by uploading it.

Regards,

Sujata

dhruv_mehta
Active Contributor
0 Kudos

Worked like a charm, thanks!

Answers (3)

Answers (3)

VenkateshG
Explorer
0 Kudos

Hi Dhruvin,

To answer your question,

1) So if I write the JS to print "Current Date" this JS will work on every clients machine right?

Answer: Not necessarily. We can write if loop to get the date value from Javascript or from the opportunity object of C4C.

to elaborate:

1) whenever the opportunity object is in draft stage, javascript will execute to show the current date.

Javascript: $.rawValue = Concat(Num2Date(Date(), "YYYY-MM-DD")

2) whenever the opportunity is frozen/win/lost, the beforesave script in SAP cloud studio can fill another date field. Then onwards, this field value can be shown in forms instead of java script value

dhruv_mehta
Active Contributor
0 Kudos

Hi Venkatesh,

I tried above thing , but The field is not poppulating with Current date.

The Second approach is something I am aware of but I dont want to do that because i dont want to get a date from a particular action, What I want is when user clicks on Preview we fetch the Current date and put it on Form.

and When u click on "Preview" onlyu event which is being called is AfterLoading and I dont want to write my code there because that event gets called for a lot of time.

Regards,

Dhruvin

dhruv_mehta
Active Contributor
0 Kudos

Hi Venkatesh,

The issue with above thing is writting the script in Form in script.

So if I write the JS to print "Current Date" this JS will work on every clients machine right?

SO if I send this PDF to my client , next day coz JS the field is updated with current date. right?

also JS not working gor me

var today =newDate();var dd = today.getDate();var mm = today.getMonth()+1;//January is 0!var yyyy = today.getFullYear();if(dd<10){
    dd ='0'+dd
}if(mm<10){
    mm ='0'+mm
} 

today = mm +'/'+ dd +'/'+ yyyy;

VenkateshG
Explorer
0 Kudos

Dear Dhruvin,

I presume the output forms work the same way as ByD. If so, my suggestion would be

1) In Adobe Life Cycle Designer we can write scripts to generate the current date whenever the opportunity is in draft stage (let's say). Anyone can do the preview.

2) once opportunity is won/finalized, we can write before save script at cloud studio to populate a field which can assume the precedence over the Adobe Life Cycle Designer script/property

Let me know if this works

G Venkatesh