Skip to content

Commit 6d60d73

Browse files
Fixed an issue where mirror-out took precedence over mirror-in, resulting in the removal of values in SNOW. (demisto#38761)
* first commit * add logs * add logs * fix pre-commit * delete after * remove redundant * add rn * fix tests * fix rn * fix rn * fix rn * fix rn * Update Packs/ServiceNow/ReleaseNotes/2_7_12.md Co-authored-by: ShirleyDenkberg <[email protected]> * fix * fix * remove log * remove log * remove log * small fix * fix tests --------- Co-authored-by: ShirleyDenkberg <[email protected]>
1 parent c91bd5f commit 6d60d73

File tree

4 files changed

+25
-61
lines changed

4 files changed

+25
-61
lines changed

Packs/ServiceNow/Integrations/ServiceNowv2/ServiceNowv2.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3050,37 +3050,39 @@ def update_remote_system_command(client: Client, args: dict[str, Any], params: d
30503050
"""
30513051
parsed_args = UpdateRemoteSystemArgs(args)
30523052
if parsed_args.delta:
3053-
demisto.debug(f"Got the following delta keys {list(parsed_args.delta.keys())!s}")
3053+
demisto.debug(f'Got the following delta {parsed_args.delta}')
3054+
demisto.debug('The following keys appears in data but not in delta '
3055+
f'{set(parsed_args.data.keys())-set(parsed_args.delta.keys())}')
30543056

30553057
ticket_type = client.ticket_type
30563058
ticket_id = parsed_args.remote_incident_id
30573059
closure_case = get_closure_case(params)
30583060
demisto.debug(f"closure case= {closure_case}")
30593061
is_custom_close = False
30603062
close_custom_state = params.get("close_custom_state", None)
3061-
demisto.debug(f"state will change to= {parsed_args.data.get('state')}")
3063+
demisto.debug(f"state will change to= {parsed_args.delta.get('state')}")
30623064
if parsed_args.incident_changed:
30633065
demisto.debug(f"Incident changed: {parsed_args.incident_changed}")
30643066
if parsed_args.inc_status == IncidentStatus.DONE:
30653067
demisto.debug("Closing incident by closure case")
30663068
if closure_case and ticket_type in {"sc_task", "sc_req_item", SIR_INCIDENT}:
3067-
parsed_args.data["state"] = "3"
3069+
parsed_args.delta["state"] = "3"
30683070
# These ticket types are closed by changing their state.
30693071
if closure_case == "closed" and ticket_type == INCIDENT:
3070-
parsed_args.data["state"] = "7" # Closing incident ticket.
3072+
parsed_args.delta["state"] = "7" # Closing incident ticket.
30713073
elif closure_case == "resolved" and ticket_type == INCIDENT:
3072-
parsed_args.data["state"] = "6" # resolving incident ticket.
3074+
parsed_args.delta["state"] = "6" # resolving incident ticket.
30733075
if close_custom_state: # Closing by custom state
30743076
demisto.debug(f"Closing by custom state = {close_custom_state}")
30753077
is_custom_close = True
3076-
parsed_args.data["state"] = close_custom_state
3078+
parsed_args.delta["state"] = close_custom_state
30773079

3078-
fields = get_ticket_fields(parsed_args.data, ticket_type=ticket_type)
3080+
fields = get_ticket_fields(parsed_args.delta, ticket_type=ticket_type)
30793081
demisto.debug(f"all fields= {fields}")
30803082
if closure_case:
30813083
# Convert the closing state to the right one if the ticket type is not incident in order to close the
30823084
# ticket/incident via XSOAR
3083-
if parsed_args.data.get("state") == "7 - Closed" and not is_custom_close:
3085+
if parsed_args.delta.get("state") == "7 - Closed" and not is_custom_close:
30843086
fields["state"] = TICKET_TYPE_TO_CLOSED_STATE[ticket_type]
30853087

30863088
fields = {key: val for key, val in fields.items() if key != "closed_at" and key != "resolved_at"}

Packs/ServiceNow/Integrations/ServiceNowv2/ServiceNowv2_test.py

Lines changed: 8 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2372,51 +2372,19 @@ def test_upload_entries_update_remote_system_command(mocker, mirror_entries):
23722372

23732373

23742374
def ticket_fields(*args, **kwargs):
2375-
state = "7" if kwargs.get("ticket_type") == "incident" else "3"
2376-
assert args[0] == {
2377-
"close_notes": "This is closed",
2378-
"closed_at": "2020-10-29T13:19:07.345995+02:00",
2379-
"impact": "3",
2380-
"priority": "4",
2381-
"resolved_at": "2020-10-29T13:19:07.345995+02:00",
2382-
"severity": "1 - Low",
2383-
"short_description": "Post parcel",
2384-
"sla_due": "0001-01-01T00:00:00Z",
2385-
"urgency": "3",
2386-
"state": state,
2387-
"work_start": "0001-01-01T00:00:00Z",
2388-
}
2375+
state = '7' if kwargs.get('ticket_type') == 'incident' else '3'
2376+
assert args[0] == {'state': state }
23892377

23902378
return {
2391-
"close_notes": "This is closed",
2392-
"closed_at": "2020-10-29T13:19:07.345995+02:00",
2393-
"impact": "3",
2394-
"priority": "4",
2395-
"resolved_at": "2020-10-29T13:19:07.345995+02:00",
2396-
"severity": "1 - Low",
2397-
"short_description": "Post parcel",
2398-
"sla_due": "0001-01-01T00:00:00Z",
2399-
"urgency": "3",
2400-
"state": "1",
2401-
"work_start": "0001-01-01T00:00:00Z",
2402-
}
2379+
"state": "3"
2380+
}
24032381

24042382

24052383
def update_ticket(*args):
24062384
state = "7" if "incident" in args else "3"
24072385
return {
2408-
"short_description": "Post parcel",
2409-
"close_notes": "This is closed",
2410-
"closed_at": "2020-10-29T13:19:07.345995+02:00",
2411-
"impact": "3",
2412-
"priority": "4",
2413-
"resolved_at": "2020-10-29T13:19:07.345995+02:00",
2414-
"severity": "1 - High - Low",
2415-
"sla_due": "0001-01-01T00:00:00Z",
2416-
"state": state,
2417-
"urgency": "3",
2418-
"work_start": "0001-01-01T00:00:00Z",
2419-
}
2386+
"state": state
2387+
}
24202388

24212389

24222390
@pytest.mark.parametrize("ticket_type", ["sc_task", "sc_req_item", "incident"])
@@ -2969,20 +2937,8 @@ def test_converts_close_code_or_state_to_close_reason(
29692937

29702938

29712939
def ticket_fields_mocker(*args, **kwargs):
2972-
state = "88" if kwargs.get("ticket_type") == "incident" else "90"
2973-
fields = {
2974-
"close_notes": "This is closed",
2975-
"closed_at": "2020-10-29T13:19:07.345995+02:00",
2976-
"impact": "3",
2977-
"priority": "4",
2978-
"resolved_at": "2020-10-29T13:19:07.345995+02:00",
2979-
"severity": "1 - Low",
2980-
"short_description": "Post parcel",
2981-
"sla_due": "0001-01-01T00:00:00Z",
2982-
"urgency": "3",
2983-
"state": state,
2984-
"work_start": "0001-01-01T00:00:00Z",
2985-
}
2940+
state = '88' if kwargs.get('ticket_type') == 'incident' else '90'
2941+
fields = {'state': state }
29862942
assert fields == args[0]
29872943
return fields
29882944

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
#### Integrations
3+
4+
##### ServiceNow v2
5+
6+
Fixed an issue where the mirror-out flow caused a field value from Cortex XSOAR to overlap fields in ServiceNow.

Packs/ServiceNow/pack_metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "ServiceNow",
33
"description": "Use The ServiceNow IT Service Management (ITSM) solution to modernize the way you manage and deliver services to your users.",
44
"support": "xsoar",
5-
"currentVersion": "2.7.11",
5+
"currentVersion": "2.7.12",
66
"author": "Cortex XSOAR",
77
"url": "https://www.paloaltonetworks.com/cortex",
88
"email": "",

0 commit comments

Comments
 (0)