- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2019 01:31 AM
Dears ,
Can some one assist on how to create a notification one month before the warranty expiration date for the assets .
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2019 09:13 PM
this code worked perfectly fine for 30 days i generated 9/2/2019 it gave me 9/2/2020 .
var policy = new GlideRecord('cmdb_ci');
var today = gs.nowDateTime();
var query = '';// modify your query accordingly
policy.addEncodedQuery(query);
policy.query();
//gs.log(policy);
while (policy.next()){
var total = gs.dateDiff(today,policy.getElement('warranty_expiration'), true);
//gs.log('Today: ' + today);
//gs.log('Warranty Expiration: ' + policy.getElement('warranty_expiration'));
//gs.log('Date Difference: ' + gs.dateDiff(today,policy.getElement('warranty_expiration'), true));
//gs.log('Total : ' + total);
var diff = Math.floor(total/86400);
//gs.log('Diff : ' + diff);
var no =policy.number;
//gs.log('No: ' + no);
var own = policy.owner.getDisplayValue();
//gs.log('Own : ' + own);
if (diff == 30 ){
//gs.log('diff found: ' + diff);
gs.eventQueue('Expired_warranty_SM ',policy,no);// pass your event name
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2019 10:27 PM
will you please check the below code ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2019 08:52 PM
1. create an event in Events>Registry
2. create a notification to be triggered when event is fired
3. Create a scheduled job something like below:
var policy = new GlideRecord('alm_asset');
var today = gs.nowDateTime();
var query = '^state=published';// modify your query accordingly
policy.addEncodedQuery(query);
policy.query();
while (policy.next()){
var total = gs.dateDiff(today,policy.'warranty field name', true);
var diff = Math.floor(total/86400);
var no =policy.number;
var own = policy.owner.getDisplayValue();
if ((diff == 60)|| (diff == 30)|| (diff == 30)||(diff == 10)){
gs.eventQueue('sn_compliance.policy.due.review',policy,no);// pass your event name
}
if ((diff == -10)||(diff == -30)){
gs.eventQueue('sn_compliance.policy.due.supervisor',policy,no);// pass your event name
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2019 01:46 AM
i found this on an old thread but it didnt work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2019 10:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2019 11:13 AM
If the notifications are going to a fixed audience IE just to you and the servicedesk,
I would run 1 scheduled report on a weekly basis.
That way you get 1 message, with all the records that will be impacted and it is easier to coordinate and manage the outcome for 1 message verses Xx separate messages.
- You can also add the report to a dashboard allowing it to be viewed easily by multiple people at any time.