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

Question

Question

Forms 11 New Designer: Best way to trigger change on a field input

asked on February 2, 2024 Show version history

I am trying to retrigger a lookup. I have been partially successful clearing the value out and putting it back in:
 

var guVal = LFForm.getFieldValues({fieldId: 23});

var changeGU = function(){
  console.log("function run");
  LFForm.setFieldValues({fieldId: 23}, "");
  	setTimeout(function(){
	      LFForm.setFieldValues({fieldId: 23}, guVal);
	  }, 500);
  };//end changeGU
 changeGU();

The problem, which is strange, is that not all the lookups run that are hooked to this field. I can move them up the order and they will run, but further down they do not run. 

Is there a better way to trigger a change to a field anyone is using?

Thanks!

0 0

Answer

SELECTED ANSWER
replied on February 2, 2024

First off you don't need the settimeout, your code can be rewritten like below. Note, async/await are very important when working with the LFForm object so you can confirm an action took place before proceeding. Give this a try and let me know if you have the same issue still.

var guVal = LFForm.getFieldValues({fieldId: 23});

var changeGU = async function(){
  console.log("function run");
  await LFForm.setFieldValues({fieldId: 23}, "");
  await LFForm.setFieldValues({fieldId: 23}, guVal);
};//end changeGU
changeGU();


Second, can you talk more about what you are trying to accomplish? Resetting the field will fire the "change" event again.

2 0
replied on February 5, 2024 Show version history

Thanks for this. This is working as a change event like .change() in jQuery. I haven't been creating in the Classic designer so I am just now getting to these differences.

Scenario:

I have a project where users want as close to live data as possible. It is from another system and we stage it in some tables. We pipe it in through WF to create the Forms instances on a schedule. 

Currently they have to click a Forms button (Submit, Approve, Reject) and it runs a WF that updates the variables (does a HTTP API call and pulls in the new data to the form).

They don't like that it times out their window and they have to go back to the inbox and reopen. (there are other things going on when they click and 'refresh' such as saving to the repository and combining pages, etc... so it takes close to a minute and closes out their window).

So I have a prototype to try and keep a set of SQL tables 'reasonably' current and have the form rely on lookups. I am finding that the WF I run to clear the tables out of the form does NOT clear them.  We are running WF 11x and I don't see this in the list of bugfixes from any of the updates so I'm not sure what is going on yet. I may have our vendor open up a support ticket with you. Not sure on that yet. I need to look at it again. Regardless, the non-clearing tables is effecting how I am relying on the lookups to populate.

I also want to set a button on the form for users to click and run the function you helped me with above. Especially since I have trust issues with so many lookups being relied on. I know I'll need to update Forms to Update 5 before that will work. We are currently vetting that in our Dev. 

There is a bit of a cyclical looking up when the form loads. I tried using this to stop the lookup so it would only run once via the function you helped me with:
 

LFForm.onLookupTrigger(function (){
					if (LFForm.getFieldValues({fieldId: 23}) !== null) {
					return {cancelLookup: true};
					}
					}, {lookupRuleId: 1}); 

It seems like applying cancelLookup on one lookupRuleId kills all others. Is that true? I had made rows like this one for all lookupRuleId's but they all stopped responding after the first one runs. No errors in console. 

The goal with the cancelLookup is to actually load the correct data faster. Right now it's trying to run the lookup on load, does not work correctly, then your function 'changes' my lookup field and everything populates correctly. So yeah, I've got bugs :)

Thanks!

0 0

Replies

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

Sign in to reply to this post.