<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Group by(location field) incidents in flow designer. in Community Central forum</title>
    <link>https://www.servicenow.com/community/community-central-forum/group-by-location-field-incidents-in-flow-designer/m-p/2994855#M446</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need some assistance with creating a flow in ServiceNow using Flow Designer. My goal is to make group incidents of x sub category by location and, if there are more than 5 incidents in the same location and sub category, create a parent incident and link the minor incidents to this parent incident. Here's what I'm trying to achieve:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Group Incidents by Location 1: Retrieve all open incidents with sub category x and group them based on their location.&lt;/P&gt;&lt;P&gt;2. Check Incident Count: For each location, check if there are more than 5 incidents.&lt;/P&gt;&lt;P&gt;3. Create Parent Incident: If any location has more than 5 incidents with sub category x, create a new parent incident.&lt;/P&gt;&lt;P&gt;4. Link Minor Incidents: Update each of the minor incidents in that category to set the newly created parent incident as their parent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I achieve this,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in Advance.&lt;/P&gt;&lt;P&gt;Raj.&lt;/P&gt;</description>
    <pubDate>Sat, 20 Jul 2024 05:33:35 GMT</pubDate>
    <dc:creator>Rajugoud</dc:creator>
    <dc:date>2024-07-20T05:33:35Z</dc:date>
    <item>
      <title>Group by(location field) incidents in flow designer.</title>
      <link>https://www.servicenow.com/community/community-central-forum/group-by-location-field-incidents-in-flow-designer/m-p/2994855#M446</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need some assistance with creating a flow in ServiceNow using Flow Designer. My goal is to make group incidents of x sub category by location and, if there are more than 5 incidents in the same location and sub category, create a parent incident and link the minor incidents to this parent incident. Here's what I'm trying to achieve:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Group Incidents by Location 1: Retrieve all open incidents with sub category x and group them based on their location.&lt;/P&gt;&lt;P&gt;2. Check Incident Count: For each location, check if there are more than 5 incidents.&lt;/P&gt;&lt;P&gt;3. Create Parent Incident: If any location has more than 5 incidents with sub category x, create a new parent incident.&lt;/P&gt;&lt;P&gt;4. Link Minor Incidents: Update each of the minor incidents in that category to set the newly created parent incident as their parent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I achieve this,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in Advance.&lt;/P&gt;&lt;P&gt;Raj.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jul 2024 05:33:35 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/group-by-location-field-incidents-in-flow-designer/m-p/2994855#M446</guid>
      <dc:creator>Rajugoud</dc:creator>
      <dc:date>2024-07-20T05:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: Group by(location field) incidents in flow designer.</title>
      <link>https://www.servicenow.com/community/community-central-forum/group-by-location-field-incidents-in-flow-designer/m-p/2994876#M447</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;This can be done in Flow Designer, but one piece is hard to accomplish, and that is the grouping of records.&lt;/P&gt;
&lt;P&gt;Flow Designer has (currently) no easy way of doing this, so that part will have to be a custom action that you create/run, which checks records and returns a result set on which locations contains more than 5 records.&lt;/P&gt;
&lt;P&gt;Do you still want to proceed?&lt;/P&gt;
&lt;P&gt;The alternative is a script of some sort that does the whole thing instead.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jul 2024 08:51:14 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/group-by-location-field-incidents-in-flow-designer/m-p/2994876#M447</guid>
      <dc:creator>OlaN</dc:creator>
      <dc:date>2024-07-20T08:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: Group by(location field) incidents in flow designer.</title>
      <link>https://www.servicenow.com/community/community-central-forum/group-by-location-field-incidents-in-flow-designer/m-p/2994877#M448</link>
      <description>&lt;P&gt;Thanks Olan,&lt;/P&gt;&lt;P&gt;I've have tried with the custum script, but I didn't get.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please provide sample script for script action in flow designer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;I will trigger this flow&amp;nbsp; for every 5 hrs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jul 2024 09:01:30 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/group-by-location-field-incidents-in-flow-designer/m-p/2994877#M448</guid>
      <dc:creator>Rajugoud</dc:creator>
      <dc:date>2024-07-20T09:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: Group by(location field) incidents in flow designer.</title>
      <link>https://www.servicenow.com/community/community-central-forum/group-by-location-field-incidents-in-flow-designer/m-p/2994892#M449</link>
      <description>&lt;P&gt;Something like this would work to retrieve and send back results on records/locations that has more than 4 records grouped by category.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do note, that I haven't taken into account if you should filter out records that already has a parent incident.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;// replace this variable with an input parameter when you create your custom action
var categorySelection = 'inquiry';

// the locations variable will contain a commaseparated list of all records that has more than 4 open incident on a given category
// your output from the custom action should contain it's results for further processing
var locations = getIncidentsLocations(categorySelection);

//gs.info('locations with more than 4 records: ' + locations);

function getIncidentsLocations(category){

	var arrResult = [];
	var incGA = new GlideAggregate('incident');
	incGA.addActiveQuery();
	incGA.addQuery('category', category);
	incGA.addQuery('location', '!=', '');  // if you want to filter out empty locations
	incGA.groupBy('location');
	incGA.addAggregate('COUNT');
	incGA.query();

	while (incGA.next()){
		//gs.info('Location: ' + incGA.getValue('location'));
		//gs.info('Location count: ' + incGA.getAggregate('COUNT'));
		if (parseInt(incGA.getAggregate('COUNT'), 10) &amp;gt; 4){
			arrResult.push(incGA.getValue('location'));
		}
		
	}
	return arrResult;
}&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 20 Jul 2024 09:39:22 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/group-by-location-field-incidents-in-flow-designer/m-p/2994892#M449</guid>
      <dc:creator>OlaN</dc:creator>
      <dc:date>2024-07-20T09:39:22Z</dc:date>
    </item>
  </channel>
</rss>

