Page 1 of 1

Update field

Posted: 06 Apr 2016
by ds4be
Hi
I have 2 lookup fields [severity] and [Probability], each of these look fields shows additional fields called [Severity:Value] and [Probability:Value]
I am trying to update a text field called [Potential risk factor] to equal ([Severity:Value] x [Probability:Value]) every time [severity] and [Probability] lookups are changed.
tried the following code however it is not working

// Update fields

function UpdateRiskFactor() {
var P = fd.field('Probability_x003a_Value').value();
var S = fd.field('Severity_x003a_Value').valve();
fd.field('Potential_x0020_Risk_x0020_Facto0').value((P)*(S));
}
// subscribe on status change
fd.field('Probability').change(function() {
UpdateRiskFactor();
});

fd.field('Severity').change(function() {
UpdateRiskFactor();
});
// initialise
UpdateRiskFactor();

[Severity:Value] and [Probability:Value]

Re: Update field

Posted: 06 Apr 2016
by rostislav
What do you mean - it's not working? One thing I can say straight off the bat what won't work is dynamically changing those additional field values. They are static and are only ever changed when the form is saved and refreshed.

If you want to get additional info via a lookup consider using our Cross Site Lookup product. You'd be able to dynamically request additional information and do your calculation that way. If you need more info, please ask.

Re: Update field

Posted: 06 Apr 2016
by ds4be
Sorry for the poor explanation,
The issue is that the [Potential Risk Factor] field is not being updated/changed in new or edit forms.
From my understanding of the previous response, it is not possible to dynamically update with Sharepoint native fields as they are only updated once the form is saved.
However is it possible to truncate the lookup field [Severity] / [probability] and multiply and multiply
I,e when i select a value
[severity] = 5. High
[Probability] = 2. Low,
is i possible to calculate 5 x 2 and place the result in the [Potential Risk Factor] field

Re: Update field

Posted: 06 Apr 2016
by rostislav
You'll need to do something like this:

Code: Select all

var v1 = parseInt(fd.field('Lookup1').control('getSelectedText'));
var v2 = parseInt(fd.field('Lookup2').control('getSelectedText'));
fd.field('result').value(v1*v2);

Re: Update field

Posted: 06 Apr 2016
by ds4be
sorry for the noob question, however in terms of 'getselectedtext' what do you replace this with.

Re: Update field

Posted: 06 Apr 2016
by ds4be
Got it , Thanks works Great