how to write condition if u_current_ram is not empty then only return sys_id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2024 03:00 AM
Hi Team,
I don't want to return or run this script current RAM from excel sheet or staging table is empty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2024 03:08 AM
@Prathamesh Cha1 try this:
answer = (function transformEntry(source) {
// Check if u_current_ram is not empty
if (source.u_current_ram) {
var retRam = new GlideRecord("sn_risk_advanced_risk_assessment_methodology");
retRam.addEncodedQuery("name=" + source.u_current_ram + "^state=2");
retRam.query();
if (retRam.next()) {
return retRam.sys_id; // Return the value to be put into the target field
}
}
// Return null or an empty value if no record is found or u_current_ram is empty
return null;
})(source);
…………………………………………........................................................................................
Mark it helpful 👍and Accept Solution ✅!! If this helps you to understand.
…………………………………………........................................................................................
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2024 03:17 AM - edited 08-07-2024 03:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2024 03:49 AM
@Prathamesh Cha1 try adding log to check if it returns a value.
Ensure that the u_current_ram field's data type matches what you're querying against. For instance, if name in sn_risk_advanced_risk_assessment_methodology is a string field, ensure that source.u_current_ram is also a string. Mismatched data types could cause the query to fail silently.