You are viewing limited content. For full access, please sign in.

Question

Question

cloud javascript

asked on January 28, 2022

Hello,

This is the first time trying to put JS on Cloud...

 

The form is made with the new designer.

 

There is simple requirement:

if the Value in Field 1 is A & Field 2 is B then result should be X

if the Value in Field 1 is C & Field 2 is D then result should be Y

 

All fields are Single Line fields.

 

Can anyone please help, really stuck....?

 

Regards,

S

 

0 0

Answer

SELECTED ANSWER
replied on January 28, 2022

Hi Sonia, 

Thank you for your input. Based on the scenario provided, a calculation should be the easiest route to accomplish the logic desired in the form. Looking at previous responses, a calculation along the lines what James suggested could do the trick. Here is a sample that you can use as a base for your own form: =IF(AND(a="a",b="b"),"Yes",IF(AND(c="c",d="d"),"Maybe",
"No"))

If you have more logic to handle you can use a Decision Table straight in the form, no need for Workflow. 

I hope this information helps. 

0 0

Replies

replied on January 28, 2022

I wouldn't use JS for this.  I would use a calculation on the result field.  Something like...

IF(AND(field1="A", field2="B"),"X",IF(AND(field1="C", field2="D"),"Y","!"))

Doing this off the top of my head, so the exact syntax will probably need adjustment

Check out...

https://www.laserfiche.com/support/webhelp/Laserfiche/10/en-US/administration/#../Subsystems/Forms/Content/FieldCalculations.htm

3 0
replied on January 28, 2022

If there is a reason you have to do this in JS it would be something like...

$(document).ready( function() {
    $(".Field1 input, .Field2 input").change( function () {
        const f1 = $(".Field1 input").val();
        const f2 = $(".Field2 input").val();
        if (f1=="A" && f2=="B")
            let result = "X"
        else
            if (f1=="C" && f2=="D")
                let result = "Y"
            else
                let result = "!";
    });
});

 

0 0
replied on January 28, 2022

This is for cloud?

0 0
replied on January 28, 2022

It's jQuery and JavaScript.  I don't use Cloud so I'm not certain, but the language shouldn't be any different.

0 0
replied on January 28, 2022

Thanks James, will try & report.

 

That's just the scenario, the actual case is bit long.

 

How would you use switch statement for this?

 

 

0 0
replied on January 28, 2022

I had tried the syntax in cloud with no luck....

 

Can someone please help re cloud?

0 0
replied on January 28, 2022

Hi Sonia, 

You can find some JS reference in our Help Files that details how JS works on the New Forms designer in Cloud, it is a bit different than in self-hosted, so I recommend you visit the Help Files to get acquainted with the JS options. 

Now, another alternative that you can try to work with this situation and perhaps avoid JS is use a Decision Table to handle the logic straight in the Form or with an IF calculation. 

0 0
replied on January 28, 2022 Show version history

Thanks Maria for the help files.... I didn't post question without reading it.

The decision table would need the WF to run first.... which is not ideal for this .

 

 

It would have been really helpful if you could have helped with the scenario I have....

0 0
SELECTED ANSWER
replied on January 28, 2022

Hi Sonia, 

Thank you for your input. Based on the scenario provided, a calculation should be the easiest route to accomplish the logic desired in the form. Looking at previous responses, a calculation along the lines what James suggested could do the trick. Here is a sample that you can use as a base for your own form: =IF(AND(a="a",b="b"),"Yes",IF(AND(c="c",d="d"),"Maybe",
"No"))

If you have more logic to handle you can use a Decision Table straight in the form, no need for Workflow. 

I hope this information helps. 

0 0
replied on January 28, 2022

Thanks Maria!

 

Will try & let you know!

0 0
replied on January 31, 2022

Ended up using Lookkup 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.