- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 09:22 AM
I have a database view which connects outages and change requests. I have a created a before Query business rule to add filters and check condition if begin date in outage is equal to 4 days from today. I have created the below logic. But i am not getting the value of oa_begin which is the begin date field in outage form. Can anyone please help me.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 11:57 AM
Hi @jitendrag ,
Try below code
var todayDate = new GlideDateTime();
var fourDaysFromNow = new GlideDateTime();
fourDaysFromNow.addDaysUTC(4);
var fourDaysDateString = fourDaysFromNow.getDisplayValue().split(' ')[0];
var oaBegin = current.getValue('oa_begin').split(' ')[0];
if (oaBegin == fourDaysDateString) {
current.addQuery('oa_type', 'planned');
current.addEncodedQuery("cr_state=-2^ORcr_state=-1");
}
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 10:19 AM
Hi @jitendrag ,
Try to gliderecord outage table as below
var todayDate = new GlideDateTime();
todayDate.addDays(4);
var outageGR = new GlideRecord('outage');
outageGR.addQuery('oa_begin', todayDate);
outageGR.query();
if (outageGR.next()) {
current.addQuery('oa_type', 'planned');
var queryString = "cr_state=-2^ORcr_state=-1";
current.addEncodedQuery(queryString);
}
Please mark it as helpful and solution proposed if it works for you.
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 10:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 11:57 AM
Hi @jitendrag ,
Try below code
var todayDate = new GlideDateTime();
var fourDaysFromNow = new GlideDateTime();
fourDaysFromNow.addDaysUTC(4);
var fourDaysDateString = fourDaysFromNow.getDisplayValue().split(' ')[0];
var oaBegin = current.getValue('oa_begin').split(' ')[0];
if (oaBegin == fourDaysDateString) {
current.addQuery('oa_type', 'planned');
current.addEncodedQuery("cr_state=-2^ORcr_state=-1");
}
Thanks,
Anand