Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Mobile App Builder Auto Fill assigned_to with User Variable

DJ Wolfson
Mega Sage

I'm current making a Function with an Action Item to make a new record which requires the user set a an `assigned_to` field that references the `sys_user` table. My hope is to set the Autofill variable to the current user, however I'm not having any luck getting this to work. I've tried both making a Variable of type User and passing it in, and following another post found here to script getting the user's `sys_id` to be autofilled into the `assigned_to` input. Neither of the attempts above seems to populate the field on the Mobile Agent. Does anyone have a proper way to utilize the Autofill variable to set a reference to the `sys_user` table to the current user?

1 ACCEPTED SOLUTION

Hey, sorry for the delay. After double checking our Mobile Agent app, it looks like we were never able to successfully auto-assign this field.

 

Based on the KB you sent, it looks like they're saying you need a function within a Script Include that returns the currently logged in user. Here's documentation for getting User information: https://developer.servicenow.com/dev.do#!/reference/api/sandiego/server_legacy/c_GlideSystemAPI%23r_...

 

I'll be honest, the article isn't very telling, but I think they're trying to say the function needs to return an object like this:

function getUserObject() {
    var object = {
        'Value': gs.getUserID(),
        'Display Value': gs.getUserDisplayName()
    };

    return object;
}

The KB is pretty odd, so the keys I gave above may not be what they actually are... I'm just going based off the KB. 

View solution in original post

5 REPLIES 5

Thanks @BalaK5 

 

Your solution helped. Only thing to keep in mind is to remove the space between Display and Value.