Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

How to call System Property in UI Action

Abhijit Das7
Tera Expert

Hi Everyone ,

 

I am calling System Property inside UI Action. But whenever I adding system property in UI Action , UI Action stops working - it becomes non clickable.

 

uiaction1.PNG

 

System Property:

sys.PNG

 

Note- Both System Property and UI Action are same scope

 

cc: @Ankur Bawiskar @PavanK960672992 

 

Thanks in advance

1 ACCEPTED SOLUTION

@Abhijit Das7 

that's correct. you need to have script include if you have to use GlideAjax.

I hope you can create script which uses GlideAjax and the required client callable script include

this link has the sample script; enhance it as per your requirement

How do I access the system property in UI page client script? 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

6 REPLIES 6

@Abhijit Das7 

1st thing -> put that code inside the callback method and not outside

that's the reason you are getting undefined for that variable

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Not applicable

This script example can help :

 

Client-side Script:

function getProperty(propertyKey) {
    var ga = new GlideAjax('YourScriptIncludeName');
    ga.addParam('sysparm_name', 'getPropertyValue');
    ga.addParam('sysparm_property_key', propertyKey);
    ga.getXML(function(response) {
        var propertyValue = response.responseXML.documentElement.getAttribute('answer');
        // Use the propertyValue as needed
        alert('Property Value: ' + propertyValue);
    });
}

 

Server Side script :

var YourScriptIncludeName = Class.create();
YourScriptIncludeName.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getPropertyValue: function() {
        var propertyKey = this.getParameter('sysparm_property_key');
        var propertyValue = gs.getProperty(propertyKey);
        return propertyValue || '';
    },
    type: 'YourScriptIncludeName'
});

 

I hope this logic can help !!