- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi everyone,
I'm new to ServiceNow developement and working on a requirement where I need to display service offers on the front end based on values from the u_offer_id table. Specifically, I want to conditionally show warranty and additional service offer options depending on the Warranty AUD and Additional AUD values.
Here are the two scenarios I'm trying to handle:
- Scenario 1
GetService response contains Warranty details with AUD = 001, with AUD > 001 AND AdditionalServicesDetail with AUD = 001
Expected Result: when Order ID created, and after offer selected, on back end, Offer IDs are :
- WarrantyDetails with AUD =001
- WarrantyDetails with AUD > 001
- AdditionalserviceDetails with AUD =001.
On Front End, Service Offer displayed are:
- Warranty Service Option(s) with SLA = 1 Day
- Warranty Service Option(s) with SLA > 1 Days
Additional Service Option is not displayed.
- Scenario 2
GetService response contains WarrantyServiceDetails with AUD > 001 AND AdditionalServicesDetail with AUD = 001
Expected Result: when Order ID created, and after offer selected, on back end, Offer IDs are :
- WarrantyServiceDetails with AUD > 001
- AdditionalserviceDetails with AUD =001.
On Front End, Service Offer displayed are:
- Warranty Service Option(s) with SLA > 1 Days
- AdditionalserviceDetails option with SLA = 1 Day is displayed.
var grOfferId = new GlideRecord('u_offer_id');
grOfferId.addQuery('u_order_number', order);
grOfferId.query();
if (grOfferId.next())
{
data.serviceTypeFilter = '';
if (grOfferId.u_order_type == 'Warranty')
{
}
Can someone help validate if this logic correctly handles both scenarios?
Any suggestions to improve or optimize this would be greatly appreciated!
Thanks in advance 🙏
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @karunyamd22,You’re pulling offers from the custom table u_offer_id based on an order number.
You need to decide which offers to show on the front end based on warranty vs additional services and their AUD values.
Currently, the script only checks if:
An offer exists for that order
The u_order_type is Warranty
But right now you’re not checking the AUD values or the AdditionalServicesDetail at all.
try this
var grOfferId = new GlideRecord('u_offer_id');
grOfferId.addQuery('u_order_number', order);
grOfferId.query();
data.serviceTypeFilter = [];
while (grOfferId.next()) {
if (grOfferId.u_order_type == 'Warranty') {
if (grOfferId.u_aud == '001') {
data.serviceTypeFilter.push('Warranty SLA = 1 Day');
} else if (parseInt(grOfferId.u_aud) > 1) {
data.serviceTypeFilter.push('Warranty SLA > 1 Day');
}
}
if (grOfferId.u_order_type == 'Additional') {
if (grOfferId.u_aud == '001') {
data.serviceTypeFilter.push('Additional SLA = 1 Day');
}
}
}
If you require an explanation of the script in detail, please let me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @karunyamd22,You’re pulling offers from the custom table u_offer_id based on an order number.
You need to decide which offers to show on the front end based on warranty vs additional services and their AUD values.
Currently, the script only checks if:
An offer exists for that order
The u_order_type is Warranty
But right now you’re not checking the AUD values or the AdditionalServicesDetail at all.
try this
var grOfferId = new GlideRecord('u_offer_id');
grOfferId.addQuery('u_order_number', order);
grOfferId.query();
data.serviceTypeFilter = [];
while (grOfferId.next()) {
if (grOfferId.u_order_type == 'Warranty') {
if (grOfferId.u_aud == '001') {
data.serviceTypeFilter.push('Warranty SLA = 1 Day');
} else if (parseInt(grOfferId.u_aud) > 1) {
data.serviceTypeFilter.push('Warranty SLA > 1 Day');
}
}
if (grOfferId.u_order_type == 'Additional') {
if (grOfferId.u_aud == '001') {
data.serviceTypeFilter.push('Additional SLA = 1 Day');
}
}
}
If you require an explanation of the script in detail, please let me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @TejasSN_LogicX ,
Thankyou so much for your support.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
If my response helped you, please mark it as the correct answer and close the thread. This way, others in the community can benefit too.
Regards,
TejasSN_LogicX
ServiceNow Developer | HackaNow Finalist | Community Contributor
📧 tejas.adhalrao11@gmail.com
🔗 LinkedIn