Unable to set value to a Catalog Item Variable in Service Portal

reginabautista
Kilo Sage

Hi everyone,

I am trying to set a value to a catalog item variable via Catalog Client Scripts. It is working if being loaded in native UI but when opening in Service Portal the value is not being set. I'm really baffled at this. Anyone know why? Thanks - Regina

Here's the code (onLoad):

        g_form.setValue('variables.url', 'test');

Native UI:

find_real_file.png

Service Portal:

find_real_file.png

1 ACCEPTED SOLUTION

Hmm...could you post your entire client script? Also, make sure you have UI Type marked as Both on the catalog client script record itself.


View solution in original post

10 REPLIES 10

Alexander Ander
Tera Contributor

Seems to be a timing problem with angularJS. Using a setTimeout call seems to fix it;

You'll want to change

g_form.setValue('comments',new Date());

to

setTimeout(function() {
    g_form.setValue('comments',new Date());
}, 0);

Essentially pushing the setValue call to the next execution stack so that the value set happens after the AngularJS evaluation finishes.