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

Question

Question

Custom html Button in Collection on New Forms Designer to Preview Documents

asked on January 22, 2024

Hi,

We have used the Classic designer for all our development projects, but we have been looking at the new designer since it will solve some of our issues related to bugs being logged on the old designer (Collections and Table large lookup takes long KB: 1014497). I have been looking through many posts and it is really just the beginning. We have tried some scripts as well to see how things will work on the New Forms Designer. I think we were spoiled with all the nice documentation and code we could use for the Classic Designer.  

I have looked at this article https://doc.laserfiche.com/laserfiche.documentation/11/administration/en-us/Default.htm#../Subsystems/Forms/Content/Javascript-and-CSS/JavaScript-in-the-Forms-Designer.htm?TocPath=Forms%257CCreating%2520a%2520Form%257C_____9 to see how this works.

 

Does anyone have a reference or code how we would use the New forms designer to Preview documents either in an Iframe or open up a document to Web Client in n new tab. It would be handy to see how the reference will work on the external url vs inline. Even if you can explain, then that will be really handy please.

 

(The below are test data and not actual data, but what I would like to achieve is to open the bottom URL in a new window linked to web client.)

 

Any guidance will be greatly appreciated. 

 

Kind Regards,

Gert

0 0

Answer

APPROVED ANSWER SELECTED ANSWER
replied on January 22, 2024

You can modify a Custom HTML field using the 'content' setting in changeFieldSettings. The key here is to perform your URL generation using the index (i.e., the row number) of the field. This code should be enough to get you on track. If you are loading the IDs from a lookup, you can listen to the on change event and pass the index of the field from the event parameter, and if the IDs exist on form load, you can just use the code as is.

 

// get all urls from url column
const urls = LFForm.getFieldValues({ fieldId: 13 });
// iterate the url list
for (let i=0; i<urls.length; i++) {
  const url = urls[i];
  // set the custom html field content to the url at its row
  LFForm.changeFieldSettings({ fieldId: 12, index: i }, {
      content: `<a href="${url}" target="_blank">google</a>`
  });
}

 

2 0

Replies

replied on January 22, 2024

Hi Zachary,

Thank you for sharing your code, this has helped and we got it working perfectly!

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

Sign in to reply to this post.