Update field

rss

Posted by ds4be - Apr 6 ’16 at 03:46

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]

 

 

  • rostislav
    rostislav
    Moderator
    Member for: 7 years 10 days
    #1 by rostislav Apr 6 ’16 at 07:46

    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
    Member
    Member for: 7 years 6 months 8 days
    #2 by ds4be Apr 6 ’16 at 09:08

    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

  • rostislav
    rostislav
    Moderator
    Member for: 7 years 10 days
    #3 by rostislav Apr 6 ’16 at 09:21

    [#2]:

    You'll need to do something like this:

    var v1 = parseInt(fd.field('Lookup1').control('getSelectedText'));
    var v2 = parseInt(fd.field('Lookup2').control('getSelectedText'));
    fd.field('result').value(v1*v2);
    
  • ds4be
    Member
    Member for: 7 years 6 months 8 days
    #4 by ds4be Apr 6 ’16 at 11:44

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

  • ds4be
    Member
    Member for: 7 years 6 months 8 days
    #5 by ds4be Apr 6 ’16 at 11:54

    Got it , Thanks works Great

Displaying 1 to 5 of 5 messages