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

Question

Question

Read-Only Field Populated by Calculation Not Saving Value

asked on August 7, 2024 Show version history

I have 2 fields, a drop-down field and a currency field. The drop-down field has values of 1-10. The currency field is marked read-only using the field properties and has a calculation based on the number selected on the drop-down field it populates a number in the currency field.

The calculation works on the initial form. Once it is submitted and goes to the first user task in the process the currency field shows a value of 0. I somewhat expect it not to save the value populated because it is a read-only field, but I would have expected the value to be populated again based on the calculation when it is opened at the user task. Is this working as designed? We are using the Modern Designer with Forms version 11.0.2311.50564.

0 0

Replies

replied on August 9, 2024

Watching this thread as we're also having some formulas that aren't re-calculating upon sending back for correction. In the old designer we used to just hit the target field with a .change() to re-trigger the formula, but I'm not sure how to do that in the modern designer.

1 0
replied on August 9, 2024

Is this cloud or self hosted? Not necessarily relevant to this issue, but you can simulate a change with this. It is verbose, but occasionally there's a need for it.

const resetField = { fieldId: 2 };
const oldValue = LFForm.getFieldValues(resetField);
LFForm.setFieldValues(resetField, "")
  .then(() => {
    LFForm.setFieldValues(resetField, oldValue)
  });
 
 
 
1 0
replied on August 9, 2024

It's self-hosted. I did try a setFieldValues but this is a field in a collection and from what I've found that function doesn't work on collections.

1 0
replied on August 13, 2024

I mocked up some code based on the example Zachary gave and some code I have used for looping through a set of fields in a collection/table. I have not tested it but it may work with tables or collections.

If this works it could be rewritten so the field id is passed in then it could be used for multiple fields on the same form.

 

const resetFieldID = 2;

function resetFunctionFields() {
  let resetFields;
  let currIndex = 0;
  let currOldValue;
  
  resetFields = LFForm.findFieldsByFieldId(resetFieldID); 
  
  /* loop through all fields */
  resetFields.forEach(async function (currField) {

    currOldValue = LFForm.getFieldValues(currField);
    
    LFForm.setFieldValues({fieldId: resetFieldID, index: currIndex}, "")
      .then(() => {
      LFForm.setFieldValues({fieldId: resetFieldID, index: currIndex}, currOldValue)
    });
    
    currIndex++; 
  }); 

};

/* on load */
resetFunctionFields();  

 

0 0
replied on August 7, 2024

I setup a basic form based on your field setup, but the value remained on the same form and using the field in a second form on the next step.  I'm on the same version.  What is your calculation?

0 0
replied on August 7, 2024

=IF(Tier="1",1,IF(Tier="2","1,000",IF(Tier="3","5,000",IF(Tier="4","10,000",IF(Tier="5","25,000",IF(Tier="6","50,000",IF(Tier="7","100,000",IF(Tier="8","250,000",IF(Tier="9","750,000",IF(Tier="10","5,000,000", 0))))))))))

0 0
replied on August 7, 2024

I see what you are saying. 

If you use the =Tier calc and assign values to the drop downs the value remains on the next step.  I'm sure you want to show the $0.00 default value though.  Seems odd that it wouldn't recal the IF statement when the form is open.

0 0
replied on August 7, 2024

Since it's a field calculation I would expect it to behave the same way as a lookup rule and keep the value even if it's read-only, but even stranger, that like you said, it doesn't kick off the field calculation again when the form is opened.

1 0
replied on August 8, 2024

Is the second form not assigned to a user? I'm checking with the team if this is a known issue or not

0 0
replied on August 8, 2024

It is all a single form.

0 0
replied on August 9, 2024

Right but is this the form that goes to the second user assigned to them? Or are they viewing it without clicking the "Assign to Me" button?

 
 
 
0 0
replied on August 9, 2024

This is the form that goes to the second user assigned to them.

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

Sign in to reply to this post.