- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 03:30 AM
Hi all,
I'm currently working in a reporting governance database view etc., but have come to a struggle.
My requirement is that I would like to combine the formula indicators together with the contributing indicators in a database view or similar. Both the formula indicator and the contributing indicators is placed in the pa_indicators table, where the are combined with the system definitions relationships.
How can I combine this in one view - any good suggestions? Custom table, database view etc?
@Mark Manders, @Dr Atul G- LNG, @Community Alums, @Tai Vu @Ankur Bawiskar - I know you're highly skilled, so maybe a good suggestion from one of you guys?
Best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2024 10:41 PM
Hi @AndersBGS
Not sure if this's late for you. It's been a marathon of long days lately.
There you go!
Business Rule Before Insert/Update/Delete
Order: 9999 (last execution)
Conditions: Type is Formula
(function executeRule(current, previous /*null when async*/ ) {
if(current.operation() === 'delete'){
deleteContributors(current.getUniqueValue(), '');
return;
}
var contributors = SNC.PAFormula.getIndicators(current.formula.toString());
deleteContributors(current.getUniqueValue(), contributors);
if(gs.nil(contributors)){
return;
}
contributors = contributors.split(',');
for (var i in contributors) {
insertContributors(current.getUniqueValue(), contributors[i]);
}
})(current, previous);
function insertContributors(formula_indicator, contributor) {
var gr = new GlideRecord('u_formula_contributor');
gr.addQuery('u_formula_indicator', formula_indicator);
gr.addQuery('u_contributing_indicator', contributor);
gr.query();
if (gr.hasNext()) {
return;
}
gr.initialize();
gr.setValue('u_formula_indicator', formula_indicator);
gr.setValue('u_contributing_indicator', contributor);
return gr.insert();
}
function deleteContributors(formula_indicator, contributors) {
var gr = new GlideRecord('u_formula_contributor');
gr.addQuery('u_formula_indicator', formula_indicator);
gr.addQuery('u_contributing_indicator', 'NOT IN', contributors);
gr.query();
gr.deleteMultiple();
}
The reason for choosing a Before rule is primarily due to the delete case. After deletion, we're unable to retrieve associated contributor records.
You may consider having an After rule for Insert/Update and another Before rule for Delete (or Cascade configuration or some other around).
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 04:14 AM
Hi @Tai Vu ,
Thank you so much - this works like a charm.
Best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/