Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to remove/update the Secondary Contact in an incident using CPM?

Vaishali RajputOct 4 2021

Hi,
I am trying to remove the secondary contacts from an incident for a certain contact once that contact's primary email id is changed, I am able to successfully update the email if of a contact, but somehow facing difficulty in removing the secondary contact from all the incidents of that particular contact.
For example -
I have a contact with email id abc@abc.com and it has 3 incidents,
then I want that whenever the primary email for contact changes from abc@abc.com to abc@cba.com, all the incidents of that contact, should remove the secondary contact from them.
Currently, I am using this,
private static function multipleIncidents($contact_update) {
try {
foreach ($contact_update as $eachContactIncidentID) {
$contact_incident_update = RNCPHP\Contact::fetch($eachContactIncidentID);
//IF you want to fetch Primary mail
if (isset($contact_incident_update -> Emails[0])) {
//$Contact_Email = $contact_incident_update -> Emails[0] -> Address;
$Contact_Email = $contact_incident_update -> Emails[0];
}
$incident_contacts = RNCPHP\ROQL::query("SELECT PrimaryContactIncidents.ID FROM Contact WHERE Contact.CustomFields.c.source_system=".$source_system." and Contact.Emails.EmailList.Address in (" .$Contact_Email. ") LIMIT 100") -> next();
while ($eachConIncID = $incident_contacts -> next()) {
if ($eachConIncID['ID'] != null) {
$IncObject = RNCPHP\Incident::fetch($eachConIncID['ID']);
//Removing secondary contacts
$f_count = count($IncObject -> OtherContacts);
if($f_count > 0 ){
for($f = ($f_count-1); $f >=0 ; $f--) {
$IncObject -> OtherContacts-> offsetUnset($f);
}
}
echo 'Updating Incident id : ' . $IncObject -> ID . "\n";
$IncObject -> save(RNCPHP\RNObject::SuppressAll);
}
}
}
Please suggest how to resolve this query.
Thanks

Comments
Post Details
Added on Oct 4 2021
1 comment
340 views