We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to call system property in client script

praveen47
Tera Contributor

Hi All, 

 

I have a requirement like 

Currently we have On change client script on one catalog item. In that CS we are using widget sys_id for making functionality. 

Customer wants to call to sys_id from system property

    //  var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
    var css_text = '<style> p{color: red;}' +
        '</style>';
    var html2 = css_text + html1;
    // 	
    // Use spModal to pop the HTML
    if (newValue == 'Yes') {
        spModal.open({
            title: 'Please provide your response below: ',
            widget: '5587c46e47e9611053b8bb1e436d4385',
            buttons: [{
                label: 'No',
                cancel: true

            }, {
                label: 'Yes',
                primary: true
            }]
        }).then(function(answer) {
            g_form.setValue('this_issue', 'Yes');
        }, function() {
       g_form.setValue('issue', 'No');
        });
    }
}

 

I have created a new sys property and stored the sys_id, need to call sys property into Client script. can any one help me  on this 

2 REPLIES 2

James Chun
Kilo Patron

Hi @praveen47,

 

You can either use an AJAX call to fetch the data or use a Display Business Rule and save the property in the g_scratchpad variable.

 

Cheers

Harish KM
Kilo Patron

Hi @praveen47 you cannot call system property directly in client script, you can use display business rule or client callable script include.

 

for your scenario you need a client callable script include

Regards
Harish