set value using client script

polodre2
Tera Contributor

I have a script that sets the value from another field on the form but it seems to be adding extra characters to the end.

The client script is read the Parent Agreement number and setting it in the field information:

 

polodre2_0-1706886533104.png

polodre2_1-1706886629941.png

The highlighted field should be showing the exact value from the Parent Agreement field but it adds -J001.

1 ACCEPTED SOLUTION

Aniket Chavan
Tera Sage
Tera Sage

Hello @polodre2 

Please give a try to the script below and see how it works for you.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    var choiceoption = g_form.getValue('u_art_4_2_1_dp1_fin_obl');
    var getNameValue = g_form.getDisplayValue('u_parent_agreement');

    if (choiceoption == 'No Cost Option') {
        var message = 'ARL CRADA + (' + getNameValue + ') Article 5.2.1, "No Cost Option" has been chosen for technical efforts under this JWS';
        g_form.showFieldMsg('u_art_4_2_1_dp1_fin_obl', message, 'info');
        g_form.addInfoMessage(message);
    } else if (choiceoption == 'Payment to ARL Option') {
        var message = 'ARL CRADA + (' + getNameValue + ') Article 5.2.2, "Payment to ARL Option" has been chosen for technical efforts under this JWS';
        g_form.showFieldMsg('u_art_4_2_1_dp1_fin_obl', message, 'info');
        g_form.addInfoMessage(message);
    }
}

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks,

Aniket

View solution in original post

8 REPLIES 8

Hello @polodre2 

 

Please check if any default value is assigned for parent or assigning field.

 

 

Thanks

Jagadish

Aniket Chavan
Tera Sage
Tera Sage

Hello @polodre2 

Please give a try to the script below and see how it works for you.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    var choiceoption = g_form.getValue('u_art_4_2_1_dp1_fin_obl');
    var getNameValue = g_form.getDisplayValue('u_parent_agreement');

    if (choiceoption == 'No Cost Option') {
        var message = 'ARL CRADA + (' + getNameValue + ') Article 5.2.1, "No Cost Option" has been chosen for technical efforts under this JWS';
        g_form.showFieldMsg('u_art_4_2_1_dp1_fin_obl', message, 'info');
        g_form.addInfoMessage(message);
    } else if (choiceoption == 'Payment to ARL Option') {
        var message = 'ARL CRADA + (' + getNameValue + ') Article 5.2.2, "Payment to ARL Option" has been chosen for technical efforts under this JWS';
        g_form.showFieldMsg('u_art_4_2_1_dp1_fin_obl', message, 'info');
        g_form.addInfoMessage(message);
    }
}

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks,

Aniket

Debug using:

alert('choiceoption = ' + choiceoption + ', getNameValue = ' + getNameValue);

just after the two lines that set those values.

saurabh_dubey
Kilo Sage

Hi @polodre2 ,

 

1) Please check the script that populates the Parent Agreement Value,

2) Also check the value, since in one of the replies you mentioned that it is a reference field, but there might be the table where the actual data of Parent Agreement Value is stored.

 

Rest your code looks good, first lets verify these things and proceed further to solve your problem, if it haven't solved yet.