Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Trouble with Dates

Avatar

Level 2

Hi Guys,

I'm having a little trouble. I'm using LiveCycle Designer 8.1

This script is in the the "exit" event of a dropdown. (JavaScript). The objects are all on the same subform.

if (WO_pentair_win.rawValue == -5)

vWO_pentair_win.rawValue = "" ;

WO_pentair_win_date.rawValue = Date(0) ; < -- I would like to set the Date field to blank

else {

vWO_pentair_win.rawValue = WO_pentair_win.rawValue

WO_pentair_win_date.rawValue = Date() <- I would like to set the display filter to MM-DD-YYY but can't seem to get this to take.

}

Any help is greatly appreciated!

Ken

1 Accepted Solution

Avatar

Correct answer by
Level 10

Replace the code in the exit event with the below..

Change the language to FormCalc in Script editor.

if(WO_pentair_win.rawValue == -5)then

vWO_pentair_win.rawValue = "";

WO_pentair_win_date.rawValue = "";

else

vWO_pentair_win.rawValue = WO_pentair_win.rawValue;

WO_pentair_win_date.rawValue = Num2Date(Date(),"YYYY-MM-DD");

endif

Let me know if you still have issues..

Thanks

Srini

View solution in original post

13 Replies

Avatar

Level 9

Hello Ken,

WO_pentair_win_date.rawValue = Date() <- I would like to set the display filter to MM-DD-YYY but can't seem to get this to take. overe here.

Are you using any date functions over here, for ex : Date2Num or Num2Date? If not, you can select the appropriate display pattern by clicking the pattern of the date field.

Thanks,Bibhu.

Avatar

Level 2

Bibhu,

I already had tried both of the possible lines you suggest - (WO_pentair_win_date.rawValue = ""; or WO_pentair_win_date.rawValue = null;) in my script and when I do, I get an error in the console...as:

SyntaxError: syntax error

4:XFA:form1[0]:Win_Opp_3[0]:WO_pentair_win[0]:exit

...and the else potion of the script doe not function.

As a matter of fact, if I do comment out that line then the  script functions fine.  Quite a mystery to me.

Ken

Avatar

Level 9

Hi Ken,

It's difficult to say what's happening in the form without seeing the form. Could you please share the form in Acrobat,com and give a link overe here so that I can look into the form.

Thanks,

Bibhu.

Avatar

Level 2

Bibhu,

I don't know where to upload. I looked around a bit but have never uploaded a form before.

Can you give me some guidance?    Thanks ~ Ken

Avatar

Level 9

Hi Ken,

It's quite simple. Go to Acrobat.com. Create an account if you don't have one. Then login. In top corner you will see a button called upload. Click on that brwose through the fiels you want to upload. Then click on share then publish it. Click on copy link, the link would automatically be copied. After copying the link paste it over here.

Thanks,

Bibhu.

Avatar

Level 2

Bibhu,

Wow, I have been looking everywhere...must be blind. I do have an account but don't see it.

What is the base URL at Adobe?

Avatar

Level 2

Bibhu,

Got it. I have an Adobe account but did not have an Acrobat account. Thanks to you, I do now

Here is the file link: https://acrobat.com/#d=*WDftMw1I7Umh84LpeKk2Q   LiveCycle Designer 8.2

Go to second page - click on the fist - select - drop-down. (*exit event)

Thanks ~ Ken

Avatar

Level 9

Hi Ken,

I guess you have not published the document. As a result of which I can not access it. Right click on that and publish it.

Thanks,

Bibhu.

Avatar

Level 9

Hi Ken,

I am in a hurry so not enough time to look into it. What I have figured out about that mystery you are taliking about is : You are not using braces in a if statement. So when there is one statement it works fine as it does not read the commented line. But when you delete teh comment statement it throws error as it becomes two lines. So you have to use curly braces here {}.

Thanks,

Bibhu.

Avatar

Correct answer by
Level 10

Replace the code in the exit event with the below..

Change the language to FormCalc in Script editor.

if(WO_pentair_win.rawValue == -5)then

vWO_pentair_win.rawValue = "";

WO_pentair_win_date.rawValue = "";

else

vWO_pentair_win.rawValue = WO_pentair_win.rawValue;

WO_pentair_win_date.rawValue = Num2Date(Date(),"YYYY-MM-DD");

endif

Let me know if you still have issues..

Thanks

Srini

Avatar

Level 2

Srini,

Works great..FormCalc did the trick

Thanks to you and Bibhu for your help!

Ken