I have a requirement with the selecting of computer name , we need to display the warranty end date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2024 03:24 AM
I have a requirement with the selecting of computer name , we need to display the warranty end date and in warranty left variable we need to display how much days still left for warranty exipration.
Example-SE-5CD2287V8T, Warranty Expired in 2023, The Warranty left days should show in Negative i.e -425 days. If value is in Positive, request should not move further since Warranty is still left for the device.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2024 04:01 AM
@Archana23 : Understanding your requirement, breaking down in below steps.
1. I believe warranty end date is coming from computer table , if yes then you can use "Auto populate" tab on variable of Warranty end date where you can dot walk end date from computer table field which is reference type.
2. To calculate Warrantly left(in days) variable you need to write onLoad client script call script include where you write logic. Refer this thread for script. https://www.servicenow.com/community/developer-forum/trying-to-calculate-days-remaining/m-p/1681241/...
3. For the validation of If value is in Positive, request should not move further since Warranty is still left for the device. you need to write onSubmit client script.
function onSubmit() {
var inputField = g_form.getValue('variable name'); // replace field_name with the name of the field warrantly left
var regex = /^[0-9]+$/;
if (regex.test(inputField)) {
gs.addErrorMessage("Request cannot submitted");// display an error message if the input is invalid
return false; // prevent the form from being submitted
}
return true; // allow the form to be submitted if the input is valid
}
Hope it helps.
Please mark my response as helpful/accepted if it helps.
Regards,
Priyanka Salunke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2024 04:03 AM
Hi @Archana23 ,
Let me know if I understood your requirement correctly.
Once you select the computer(which is a reference field), the warranty expired date is auto populated(i.e the warranty expiration date, present on the computer record).
And Warranty Left field is also auto populated by +ve or _ve based on the expiration date).
Let me know if I got it right, If yes then I can provide you a client script that could fulfil you requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2024 05:24 AM
Yes it's correct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2024 02:53 AM