Catalog Item Macro

Ken83
Mega Guru

Hello Community,

 

        I believe this would be something simple that i'm overlooking but I haven't found it yet. On a Catalog Item, I had a reference field to the sys_user table to indicate who the Request was for. We utilize the 2 step checkout so even though that field was populated with a name, the end user would have to enter the name again on the second page of the checkout. So, to resolve that problem, I decided to add the Macro to the Catalog Item that already exists on the second page of the checkout.(sys_display.sc_cart.requested_for). I have another reference field on the same Catalog Item. When I populate field1 with a value, I want it to trigger an onChange Client Script and populate field2(the Macro). The problem is, this isn't working with a Macro variable type. It works from one reference field to another but not for the Macro field. Any suggestions?

 

Currently, my onChange Client Script is below...

 

function onChange(control, oldValue, newValue, isLoading) {

 

  var person1 = g_form.getValue("field1");

  g_form.setValue("field2", person1);

 

}

8 REPLIES 8

I abandoned my efforts due to time constraints.


No worries Kenneth.



If you do look at it again, I'm happy to assist you with modifying my script to suit your purposes.



Regards,


Jake


to validate the value enter in the ui macro , i guess you need to use a script and glide record and manually validate the value ... API wont work as per my knowledge


randrews
Tera Guru

if you are interested in a slightly different method ...



try setting this as an on change client script inside the item... set it to change based on the requested_for and only apply to catalog items.



function onChange(control, oldValue, newValue, isLoading) {


   


    if (newValue){


          var gr = new GlideRecord('sc_cart');


          gr.addQuery('user', g_user.userID);


          gr.query();


          gr.next();


          gr.requested_for = newValue;


          gr.update();


    }


}