Update field

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
ds4be
Posts: 20
Joined: Fri Nov 07, 2014

06 Apr 2016

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]

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

06 Apr 2016

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.

ds4be
Posts: 20
Joined: Fri Nov 07, 2014

06 Apr 2016

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

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

06 Apr 2016

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);

ds4be
Posts: 20
Joined: Fri Nov 07, 2014

06 Apr 2016

sorry for the noob question, however in terms of 'getselectedtext' what do you replace this with.

ds4be
Posts: 20
Joined: Fri Nov 07, 2014

06 Apr 2016

Got it , Thanks works Great

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 15 guests