Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Scan QR code and populate the Asset value in a Asset Reference field on Incident Record Screen.

anushad
Tera Expert

Created footer function on a record screen called Scan Asset. The intent of the function is to scan a QR code and populate the value on incident record screen Asset reference field (given if asset already exists alm_asset table) . Created a Input form screen and input with Bar code type and tried to map to Asset Reference field , i am able to scan asset and populate the value in input form screen and nothing happens after. How can I achieve this ? 

Mobile App Builder --> Mobile Agent --> Scoped
Function : Scan Asset
Action item --> Type : Update --> Table: incident
Action item --> Input form screen --> Inputs(scan_caller_asset) --> Input type -->  Barcode
Action item --> Input form screen --> Variables(caller_asset) --> Asset Reference field on incident table

Action item --> Input form screen --> Input --> Autofill variable = caller_asset
Action item --> field values --> Incident Asset Reference field = input(scan_caller_asset)


2 REPLIES 2

mngreen
Tera Contributor

Hi anushad
Since I have a similar usevase I am wondering if you magnaged to solve this requirement ?

best regards

Felipe Rocha d2
Tera Contributor

You can do that on your action item script.

Something like the script below:

 

var gr = new GlideRecord("incident");

gr.get(sys_id_of_your_incident);

var asset = parm_input.your_asset_scan_name;
            if (!gs.nil(asset)) {
                var assetgr = new GlideRecord('alm_asset');
                assetgr.addQuery('asset_tag', asset);
                assetgr.query();
                if (assetgr.next()) {
                    gr.setValue('asset', assetgr.sys_id);
                }
                else {
                   gs.addErrorMessage(gs.getMessage("Asset with this tag does not exist"));
                   return;
                }
            }
gr.update();