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  

Getting Location Reference Error using ATF

SangyM
Tera Contributor

Hi Folks,

 

I have created an asset (alm_hardware) and have added my newly created location (cmn_location) in there as well as in Stockroom.

But, as soon as I am trying to close the deploy task it is showing the below error :

This step failed because the client error 'NiceError: [2025-07-25T07:34:26.352Z]: Unable to match value '' with field 'location' in table 'alm_asset'. Expecting type 'reference'
-------- STACK TRACE ---------
at [global] 'Schema' [sys_script_include:4e115aed73512300bb513198caf6a749]:274 (checkFieldType)
at [global] 'GlideQueryEvaluator' [sys_script_include:d52b3c8a08013300fa9b4300d8d67a76]:529 (setSingleValueToGlideRecord)
at [global] 'GlideQueryEvaluator' [sys_script_include:d52b3c8a08013300fa9b4300d8d67a76]:547 (setAllValuesToGlideRecord)
at [global] 'GlideQueryEvaluator' [sys_script_include:d52b3c8a08013300fa9b4300d8d67a76]:460 (update)
at [global] 'GlideQuery' [sys_script_include:864c9ebf73631300bb513198caf6a721]:368 (update)
at [sn_hamp] 'HampLoanerUtils' [sys_script_include:b83b48a073d650107e88ef66fbf6a703]:195
at [sn_hamp] 'HampLoanerUtils' [sys_script_include:b83b48a073d650107e88ef66fbf6a703]:432
at [sn_hamp] 'Update Asset on closing Deploy task' [sys_script:749b3448b74320106b866d07ee11a9e9]:2 (executeRule)
at [sn_hamp] 'Update Asset on closing Deploy task' [sys_script:749b3448b74320106b866d07ee11a9e9]:3
at [sn_hamp] 'HampLoanerUtils' [sys_script_include:b83b48a073d650107e88ef66fbf6a703]:969
at [sn_hamp] 'HAMUtils' [sys_script_include:75f6b4a453d01010249addeeff7b1294]:749
at [global] 'AssetUtils' [sys_script_include:3596241c475520003ecf706eecde2726]:705
at 'LAOTSK0001278' [sn_hamp_loaner_asset_task:e258654cebcfe210bc47f520dad0cd6f]:1
------------------------------
: no thrown error

Root cause of JavaScriptException: org.mozilla.javascript.NativeObject
JavaScript evaluation error on:
(function executeRule(current, previous) {
new sn_hamp.HampLoanerUtils().updateAssetOnDeployCompletion(current);
}(current, previous));
Stack trace:
at sys_script_include.fc70ddc629230010fa9bf7f97d737e2e.script:133 (raise)
at sys_script_include.4e115aed73512300bb513198caf6a749.script:274 (checkFieldType)
at sys_script_include.d52b3c8a08013300fa9b4300d8d67a76.script:529 (setSingleValueToGlideRecord)
at sys_script_include.d52b3c8a08013300fa9b4300d8d67a76.script:547 (setAllValuesToGlideRecord)
at sys_script_include.d52b3c8a08013300fa9b4300d8d67a76.script:460 (update)
at sys_script_include.864c9ebf73631300bb513198caf6a721.script:368 (update)
at sys_script_include.b83b48a073d650107e88ef66fbf6a703.script:195
at sys_script_include.b83b48a073d650107e88ef66fbf6a703.script:432
at sys_script.749b3448b74320106b866d07ee11a9e9.script:2 (executeRule)
at sys_script.749b3448b74320106b866d07ee11a9e9.script:3
at sys_script_include.b83b48a073d650107e88ef66fbf6a703.script:969
at sys_script_include.75f6b4a453d01010249addeeff7b1294.script:749
at sys_script_include.3596241c475520003ecf706eecde2726.script:705
at <refname>:1
: no thrown error

JavaScript evaluation error on:
(function executeRule(current, previous) {
new sn_hamp.HampLoanerUtils().updateAssetOnDeployCompletion(current);
}(current, previous));

 

Can someone please help to resolve it? I am using same location in alm_hardware and also have added same in alm_asset for some extra precautions

1 ACCEPTED SOLUTION

@SangyM 

It is recommended to use record validation after after record insert.

Better create new location using open new form and then setting the values.

 

Regards

Shaqeel


***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.

***********************************************************************************************************************





Regards

Shaqeel

View solution in original post

3 REPLIES 3

Shaqeel
Mega Sage
Mega Sage

Hi @SangyM 

 

As far I understood this error, location is a reference to cmn_location, so servicenow expect either a valid sys_id of a location OR a valid display value that can resolved to a sys_id (if using display value).

But in your case, its trying to assign '' empty, which it cannot match.

//Unable to match value '' with field 'location' in table 'alm_asset'. Expecting type 'reference'//

 

Make sure that location you are assigning actually exist in cmn_location.

You can also check the script or BR.

 

Regards

Shaqeel


***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.

***********************************************************************************************************************





Regards

Shaqeel

SangyM
Tera Contributor

@Shaqeel , I am first creating the location in cmn_location table (record insert) then I am adding that to the Stockroom and hardware (alm_hardware) tables.

@SangyM 

It is recommended to use record validation after after record insert.

Better create new location using open new form and then setting the values.

 

Regards

Shaqeel


***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.

***********************************************************************************************************************





Regards

Shaqeel