Is this possible? I want to use javascript to subtract two fields on my form. The output should be displayed on the screen and saved to a field in my list. I cannot use a SharePoint List calculated column because one item is a lookup value. That lookup value is loaded in this SharePoint List
ActualPointsComplete is the form field that the user is changing. I would like to save this calculation to a SharePoint field called 'DiffStoryPoints.' In a perfect world I would also like to change the color of 'DiffStoryPoints' based on its value.
fd.spRendered(function() {
fd.field('ActualPointsComplete').$on('change', function() {
var VarActualPoints = parseInt(fd.field('ActualPointsComplete').value);
var VarPlannedPoints = parseInt(fd.field('SprintPlanLookup:PlannedPoints').value);
fd.field('DiffStoryPoints').value = VarPlannedPoints - VarActualPoints;
});
If you using lookups and you want the value you have to use .value.LookupValue
So fd.field('SprintPlanLookup:PlannedPoints').value should be more like fd.field('SprintPlanLookup:PlannedPoints').value.LookupValue
Also double check the name of the of field as you have it on your plumsail form, it doesn't look right as characters like a : are usually replaced with something else.
If the field name contains special characheters, they are decoded to XML . Thus, the field name 'SprintPlanLookup:PlannedPoints' is invalid. The valid internal name is SprintPlanLookup_x003a_PlannedPoints
If the field is present on the form, you can get its value using this code:
Also, you can specify fields that need to be loaded from the source list in the Extra Fields property of the lookup field.
And get the extra field value using the code:
fd.field('SprintPlanLookup').value.PlannedPoints
You can change the styling of any element on the form dynamically using the Jquery library. For instance, change the background color of the field input: