<?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>topic Re: Is there a way to mass rename closed XSOAR cases? in Cortex XSOAR Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/is-there-a-way-to-mass-rename-closed-xsoar-cases/m-p/547616#M2275</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/299275"&gt;@weijielim&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can change the name of a closed incident using the command &lt;STRONG&gt;!setIncident&amp;nbsp;&lt;/STRONG&gt;from a different incident, by passing the &lt;STRONG&gt;id&lt;/STRONG&gt; of the incident you'd like to rename and the &lt;STRONG&gt;name&lt;/STRONG&gt; you'd like to give to it. If you'd like to target multiple incidents at once you will need to&amp;nbsp;wrap that command inside a for loop in an automation.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;You can use this basic automation below as an example:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import json

query = demisto.args()['query']
new_name = demisto.args()['new_name']

try:
    incidents = demisto.executeCommand('getIncidents', {'query': query, 'size': '10000'})[0]['Contents']['data']
    incident_ids = demisto.dt(incidents,'id')
except:
    demisto.results('No incidents found matching query.')
    sys.exit(0)

if not incidents:
    demisto.results('No closed incidents found matching query.')
    sys.exit(0)


res = []
for inc_id in incident_ids:
    try:
        command_res = demisto.executeCommand("setIncident", {'id': inc_id, 'name': new_name})[0]['Contents']
        if "Script failed" not in command_res:
            res.append({'Incident ID': inc_id, 'Status': "Success"})
        else:
            res.append({'Incident ID': inc_id, 'Status': "Failure"})
    except Exception as e:
        demisto.results(e)
        sys.exit(0)

demisto.results({'Type': entryTypes['note'],
    'ContentsFormat': formats['markdown'],
    'Contents': tableToMarkdown(name='Renamed Incidents', t=res)
})&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;BR /&gt;This works for both Active and Closed incidents.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Jun 2023 18:32:57 GMT</pubDate>
    <dc:creator>AbelSantamarina</dc:creator>
    <dc:date>2023-06-28T18:32:57Z</dc:date>
    <item>
      <title>Is there a way to mass rename closed XSOAR cases?</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/is-there-a-way-to-mass-rename-closed-xsoar-cases/m-p/546978#M2262</link>
      <description>&lt;P&gt;Hi, I know that we can mass rename active cases but what about mass renaming closed cases? I can rename closed cases one at a time manually but it is super tedious to do so as we have thousands of existing cases. Any suggestions? Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2023 09:37:59 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/is-there-a-way-to-mass-rename-closed-xsoar-cases/m-p/546978#M2262</guid>
      <dc:creator>weijielim</dc:creator>
      <dc:date>2023-06-23T09:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to mass rename closed XSOAR cases?</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/is-there-a-way-to-mass-rename-closed-xsoar-cases/m-p/547616#M2275</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/299275"&gt;@weijielim&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can change the name of a closed incident using the command &lt;STRONG&gt;!setIncident&amp;nbsp;&lt;/STRONG&gt;from a different incident, by passing the &lt;STRONG&gt;id&lt;/STRONG&gt; of the incident you'd like to rename and the &lt;STRONG&gt;name&lt;/STRONG&gt; you'd like to give to it. If you'd like to target multiple incidents at once you will need to&amp;nbsp;wrap that command inside a for loop in an automation.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;You can use this basic automation below as an example:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import json

query = demisto.args()['query']
new_name = demisto.args()['new_name']

try:
    incidents = demisto.executeCommand('getIncidents', {'query': query, 'size': '10000'})[0]['Contents']['data']
    incident_ids = demisto.dt(incidents,'id')
except:
    demisto.results('No incidents found matching query.')
    sys.exit(0)

if not incidents:
    demisto.results('No closed incidents found matching query.')
    sys.exit(0)


res = []
for inc_id in incident_ids:
    try:
        command_res = demisto.executeCommand("setIncident", {'id': inc_id, 'name': new_name})[0]['Contents']
        if "Script failed" not in command_res:
            res.append({'Incident ID': inc_id, 'Status': "Success"})
        else:
            res.append({'Incident ID': inc_id, 'Status': "Failure"})
    except Exception as e:
        demisto.results(e)
        sys.exit(0)

demisto.results({'Type': entryTypes['note'],
    'ContentsFormat': formats['markdown'],
    'Contents': tableToMarkdown(name='Renamed Incidents', t=res)
})&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;BR /&gt;This works for both Active and Closed incidents.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 18:32:57 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/is-there-a-way-to-mass-rename-closed-xsoar-cases/m-p/547616#M2275</guid>
      <dc:creator>AbelSantamarina</dc:creator>
      <dc:date>2023-06-28T18:32:57Z</dc:date>
    </item>
  </channel>
</rss>

