- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 02:40 AM
Hi Team,
I am fetching one record in rest message and I want only particular field.
Here I want to fetch "Apttus__FF_Agreement_Number__c"?
can anyone help me in this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 04:12 AM
this should work
var jsonString = '{"totalSize":1,"done":true,"records":[{"attributes":{"type":"Apttus__APTS_Agreement__c","url":"/services/data/v58.0/sobjects/Apttus__APTS_Agreement__c/a086t000001eHdqAAE"},"Apttus__FF_Agreement_Number__c":"00054549.0","Apttus__Contract_Start_Date__c":"2023-04-19","Apttus__Contract_End_Date__c":"2023-04-26","Account_Name__c":"ABC Account","Apttus__Status__c":"Activated"}]}';
// Parse the JSON string
var jsonObj = JSON.parse(jsonString);
// Retrieve the value for Apttus__FF_Agreement_Number__c
var agreementNumber = jsonObj.records[0].Apttus__FF_Agreement_Number__c;
alert('Apttus__FF_Agreement_Number__c: ' + agreementNumber);
Output: I tried in background script and it worked fine
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 02:47 AM
share that json here.
you should easily parse it and get that value using this
Ensure you give the correct underscore etc
var val = res.records[0].attributes['Apttus__FF_Agreement_Number__c'];
alert(val);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 04:09 AM
Hi @Ankur Bawiskar ,
Sorry @Ankur Bawiskar ,its not working please check the JOSN I have shared
Info Message{"totalSize":1,"done":true,"records":[{"attributes":{"type":"Apttus__APTS_Agreement__c","url":"/services/data/v58.0/sobjects/Apttus__APTS_Agreement__c/a086t000001eHdqAAE"},"Apttus__FF_Agreement_Number__c":"00054549.0","Apttus__Contract_Start_Date__c":"2023-04-19","Apttus__Contract_End_Date__c":"2023-04-26","Account_Name__c":"ABC Account","Apttus__Status__c":"Activated"}]}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 04:12 AM
this should work
var jsonString = '{"totalSize":1,"done":true,"records":[{"attributes":{"type":"Apttus__APTS_Agreement__c","url":"/services/data/v58.0/sobjects/Apttus__APTS_Agreement__c/a086t000001eHdqAAE"},"Apttus__FF_Agreement_Number__c":"00054549.0","Apttus__Contract_Start_Date__c":"2023-04-19","Apttus__Contract_End_Date__c":"2023-04-26","Account_Name__c":"ABC Account","Apttus__Status__c":"Activated"}]}';
// Parse the JSON string
var jsonObj = JSON.parse(jsonString);
// Retrieve the value for Apttus__FF_Agreement_Number__c
var agreementNumber = jsonObj.records[0].Apttus__FF_Agreement_Number__c;
alert('Apttus__FF_Agreement_Number__c: ' + agreementNumber);
Output: I tried in background script and it worked fine
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 02:53 AM
Hi @Prathamesh Chav ,
You can refer to the below video to understand how can we pass data using GlideAjax.
Although, if you want to pass only a single value, you can directly use the following script and use it directly in your client script (no need of JSON). Ensure varname is a string type of field
return varname;
Please mark this response as Correct Answer/ Helpful if it helped you.
Cheers,
Hardit Singh