There are multiple examples you can look at in OOTB integrations from the App Exchange
example of creating a new line in a table from artifacts action
from java.util import Date
dt = incident.addRow("deleted_artifacts")
dt.artifact_id = artifact.id
dt.type = str(artifact.type)
dt.value = str(artifact.value)
if artifact.description is None:
dt.description = ""
else:
dt.description = str(artifact.description["content"])
dt.comments = "Deleted the {}".format(Date())
modify a value in a table from a table action :
from java.util import Date
low_text = "{} \n Original ID {} {} \n Pushed back to Artifact the {}".format(row.description["content"], row.artifact_id, row.comments["content"], Date())
row.comments = "{} \n Pushed back the {}".format(row.comments["content"],Date())
incident.addArtifact(str(row.type), str(row.value), str(low_text))
From PIPL integration : loop in the JSON "results" from the integration to create line in a table and add results
Additionally add a comment on the artifact description and a more precise comment in notes, or transfer this note comment to an integration that came after using workflow properties
from java.util import Date
def add_row_to_pipl_datatable(db_timestamp, db_artifact_value, db_match_no, db_property, db_value, db_match, db_inferred):
pipl_person_data = incident.addRow("pipl_person_data")
pipl_person_data.pipl_timestamp = db_timestamp
pipl_person_data.pipl_artifact_value = db_artifact_value
pipl_person_data.pipl_possible_match_no = db_match_no
pipl_person_data.pipl_property = db_property
pipl_person_data.pipl_value = db_value
pipl_person_data.pipl_match = db_match
pipl_person_data.pipl_inferred = db_inferred
if results.success:
possible_person_counter = 0
for person in results.person_list:
possible_person_counter += 1
now = Date()
match = str(person.get("@match", ""))
inferred = str(person.get("@inferred", ""))
names = person.get("names", [])
for name in names:
add_row_to_pipl_datatable(now, artifact.value, possible_person_counter, "name", name.get("display", ""), match, inferred)
emails = person.get("emails", [])
for email in emails:
add_row_to_pipl_datatable(now, artifact.value, possible_person_counter, "email address", email.get("address", ""), match, inferred)
add_row_to_pipl_datatable(now, artifact.value, possible_person_counter, "address_md5", email.get("address_md5", ""), match, inferred)
usernames = person.get("usernames", [])
for usrname in usernames:
add_row_to_pipl_datatable(now, artifact.value, possible_person_counter, "username", usrname.get("content", ""), match, inferred)
phones = person.get("phones", [])
for phone in phones:
add_row_to_pipl_datatable(now, artifact.value, possible_person_counter, "phone", phone.get("display_international", ""), match, inferred)
gender = person.get("gender")
if gender:
add_row_to_pipl_datatable(now, artifact.value, possible_person_counter, "gender", gender.get("content", ""), match, inferred)
dob = person.get("dob")
if dob:
add_row_to_pipl_datatable(now, artifact.value, possible_person_counter, "dob", dob.get("display", ""), match, inferred)
addresses = person.get("addresses", [])
for address in addresses:
add_row_to_pipl_datatable(now, artifact.value, possible_person_counter, "address", address.get("display", ""), match, inferred)
jobs = person.get("jobs", [])
for job in jobs:
add_row_to_pipl_datatable(now, artifact.value, possible_person_counter, "job", job.get("display", ""), match, inferred)
educations = person.get("educations", [])
for edu in educations:
add_row_to_pipl_datatable(now, artifact.value, possible_person_counter, "education", edu.get("display", ""), match, inferred)
user_ids = person.get("user_ids", [])
for usr_id in user_ids:
add_row_to_pipl_datatable(now, artifact.value, possible_person_counter, "user_id", usr_id.get("content", ""), match, inferred)
images = person.get("images", [])
for image in images:
image_url = """<a href='{0}'>{0}</a>""".format(image.get("url", "")) if image.get("url", "") else ""
add_row_to_pipl_datatable(now, artifact.value, possible_person_counter, "image", image_url, match, inferred)
urls = person.get("urls", [])
for url in urls:
url_url = """<a href='{0}'>{0}</a>""".format(url.get("url", "")) if url.get("url", "") else ""
add_row_to_pipl_datatable(now, artifact.value, possible_person_counter, "url", url_url, match, inferred)
raw_data = results.raw_data if results.raw_data else ""
counter = possible_person_counter if possible_person_counter > 0 else ""
rich_text = u"""<h4><b><u>Pipl Data API response for artifact_value {} returned {} {}: </h4></b></u>\n{}""".format(artifact.value, counter, results.pipl_response, raw_data)
low_text = u"""PIPL: Data API response for artifact_value {} returned {} {}""".format(artifact.value, counter, results.pipl_response)
else:
low_text = "PIPL: {} not found in Pipl.".format(artifact.value)
rich_text = low_text
if incident.properties.custom_task_id_look_emails > 1:
workflow.addProperty("task_note", {"rich_text":str(rich_text)})
else:
incident.addNote(helper.createRichText(rich_text))
if artifact.description is None:
artifact.description = unicode(low_text)
else:
artifact.description = "{} \n {}".format(artifact.description["content"], low_text)------------------------------
BENOIT ROSTAGNI
------------------------------
Original Message:
Sent: Tue April 14, 2020 05:00 PM
From: Jasmine
Subject: Manipulate a data table from scripts
Hi,
I want to create an action that manipulate data table. Is it possible to do that from script? Any document or example would be appreciated.
Best
Jasmine
------------------------------
Jasmine
------------------------------