Adding a Trend encoded query to a Business Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 01:27 AM
In a Business Rule, I'm wanting to add the following Trend search:
When I right click on the query and select 'Copy Query', it appears as:
sys_created_onDATEPARTMidnight hour@javascript:gs.datePart('hour','0','GE')^sys_created_onDATEPART8 am hour@javascript:gs.datePart('hour','8','LT')
I'm wanting to copy this query and apply it in a Business Rule as a condition. However, I get the following error:
If somebody could please explain what I need to do, that would be great.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 01:47 AM
Give this a try. And also, keep the string query in a double quote marks.
var query = "sys_created_onDATEPARTMidnight hour@javascript:gs.datePart('hour','0','GE')^sys_created_onDATEPART8 am hour@javascript:gs.datePart('hour','8','LT')";
current.addEncodedQuery(query);
Let me know if it works for you.
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 02:07 AM
Hi @Tai Vu I've tried the following amendments, but the field is not updating:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 03:12 AM
I'm not sure what do you intend to do. Can you be more specific on the requirements so maybe I can help to adjust your script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 03:17 AM - edited 10-09-2023 03:18 AM
Hi @Tai Vu
I'm wanting to set the value of the 'u_shift_opened_in' field depending on when the request is created. The logic should be:
If the request is created at or after midnight and before 8am, then the value of the 'u_shift_opened_in' field
should be 'Shift 1'
If the request is created at or after 8am and before 4pm, then the value of the 'u_shift_opened_in' field should be 'Shift 2'
If the request is created at or after 4pm, then the value of the 'u_shift_opened_in' field should be 'Shift 3'