Populate Item Variable using Catalog Client Script manipulating values brought over from Order Guide Rule Base.

Paul Porter
Tera Expert

I have an Order Guide with a Rule Base that's forwarding 3 different variable values to a Catalog Item.   I've written an onLoad Catalog Client Script in one of the Catalog Items with the intent of concatenating the value in each of those Catalog Item variables into a variable called purchase_title.   However, as you can probably expect, the variable I'm attempting to write to with the Catalog Client Script doesn't get populated by the script.   I've been stubbornly banging my head against this one for a few hours and its become obvious to me that I'm missing a vital piece to the puzzle.   I've read a few articles in the Community that suggest I'm on the right track, but I'm out of gas.   Any assistance would be appreciated.

function onLoad() {

        //Type appropriate comment here, and begin script below

                  var firstName = g_form_getValue('ob_pn_first_name');

                  var lastName = g_form_getValue('ob_pn_last_name');

                  var startDate = g_form_getValue('ob_pn_start_date');

        if (firstName != ""){

                  var purTitle = ('Onboarding-New Computer Purchase: ' + firstName + ' ' + lastName + '-' + startDate);

                  // g_form_addInfoMessage('The Purchase Short Description has been auto-filled for this Onboarding PurchaseNow Request');

                  g_form.setValue('purchase_title',purTitle);

        }

}

1 ACCEPTED SOLUTION

EashVerma
Giga Expert

Hello Paul,



You haven't missed any piece of the puzzle, but made a very silly mistake. Instead of g_form.getValue(), you have used g_form_getValue().



Correct your mistake and you are good to go.



Thanks.


View solution in original post

9 REPLIES 9

Nate23
Mega Guru

so ob_pn_first_name, ob_pn_last_name, and ob_pn_start_date are variables on your catalog item?



are the values being stored in the vars you declared?


Nathan... Yes and yes.



~Paul



On Jan 17, 2018 6:41 PM, "nategiere" <community-no-reply@servicenow.com>


Did you try solution provided by Eash Verma? g_form.getValue is the correct format.



Please mark this response as correct or helpful if it assisted you with your question.

EashVerma
Giga Expert

Hello Paul,



You haven't missed any piece of the puzzle, but made a very silly mistake. Instead of g_form.getValue(), you have used g_form_getValue().



Correct your mistake and you are good to go.



Thanks.