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

Discussion

Discussion

Porting Javascript to Modern Designer

posted on June 26, 2024 Show version history

Hi all,

 

I'm attempting to extract the last row of a table, to use in a lookup directly in forms.

I'm attemping this method he re here https://answers.laserfiche.com/questions/153832/Table-and-Collection-JavaScript-Event-Handlers

 

But am having a bit of trouble porting the new code to the modern designer. I am fresh to Javascript.

 

I'm using the new guide here to try and attempt this https://doc.laserfiche.com/laserfiche.documentation/11/administration/en-us/Subsystems/Forms/Content/Javascript-and-CSS/JavaScript-in-the-Forms-Designer.htm

My code is 

$(document).ready(function(){
  LFForm.onfieldChange(('.Table').on('change',function(e){
    console.log('My Table Changed!'));
  });
});

What am I missing here, push in the right direction appreciated.

 

Also as I'm experimenting, 

 

LFForm.onFieldChange(() => console.log("change"),LFForm.setFieldValues({fieldId:3}, 2), {variableName: "Single_Line"});

I was expecting that this would set the field with ID 3 to the number 2, when there was a change made however it seems to execute this before a change is made to the field?

Thanks

 

0 0
replied on July 31, 2024

Thanks, still trying to figure out the differences.

0 0
replied on June 27, 2024

Hi Shan

In the Modern Form Designer JS Window, you do not use $(document).ready(function(){, so instead your code would just look like

LFForm.onFieldBlur(() => console.log("blur"), {variableName: "Single_Line"});

Change is triggered for any change made in the field, so if you type "Steve", it would trigger the code 5 times, once for each letter you typed. So instead you would use Blur, and as you tabbed away from the field or clicked to another field, it would then only run once.

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

Sign in to reply to this post.