Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to Autofill the reference field in Mobile?

Rosfield
Tera Contributor

Hi

I created a script to autofill the contact field with the user

System Definition > Script Includes

var GetDefaultContactValue = Class.create();
GetDefaultContactValue.prototype = {
    initialize: function() {},

    getDefaultValue: function() {
        var userId = gs.getUserID();
		var userName = gs.getUserDisplayName();
        return {
			"Value" : userId,
			"DisplayValue" : userName
		};
    },

    type: 'GetDefaultContactValue'
};

 

 Executable scripts

new sn_csm_mobile.GetDefaultContactValue().getDefaultValue();

 

This will not be executed.
Please tell me what is wrong with this script

 

I referenced these articles

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1166399

https://www.servicenow.com/community/mobile-apps-platform-forum/mobile-app-builder-auto-fill-assigne...

5 REPLIES 5

HarshithaK
Tera Contributor

Hi @Rosfield ,

Autofill variable can also be done through creating a function, u need to provide the input form screen and give the input and variables
Under the Autofill variable select the variable that you have created.

Screenshot 2025-04-08 at 4.26.28 PM.png

 

Thanks