
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2024 08:52 AM
Hi,
I am trying to create a database view that will give me all the SLAs linked to Incidents, where the Incident doesn't have an Incident Task related to it.
I am struggling trying to do this using a join.
Does anyone have an idea how I can do this?
Thanks,
Ayman
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2024 11:40 AM
I had some time finally to look into the problem and below you'll find how I solved this in my PDI.
This is how the definition of the database view looks like:
The where clause for table task_sla is:
not exists (select 1 from `task` inct where `inct`.`sys_class_name` = 'incident_task' and `inct`.`a_ref_1` = `inc`.`sys_id`)
The where clause for table incident is:
inc.sys_id = tsla.task
The key part of the solution is finding the storage alias for field incident on table incident_task - a_ref_1 in the where clause for table task_sla.
For this one should open table Storage Column Aliases (sys_storage_alias) and filter it down to where Table (table_name) is incident_task and Element name (element_name) is incident:
Whatever is in column Storage alias (storage_alias) - a_ref_1 in my PDI - should be used.
(B.t.w. all the back-ticks are not really necessary, not exists (select 1 from task inct where inct.sys_class_name = 'incident_task' and inct.a_ref_1 = inc.sys_id) works just fine).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 07:35 AM
Yeah, it should be the same but it's better to check 🙂
Glad it works, and thanks for marking the correct answer.