• Dan Jones
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Hello,

I'm trying to perform a simple Upsert operation with a trigger on the AdditionalNumber object (related to the Call Center stuff).

However, I'm getting the error message:
DML not allowed on AdditionalNumber

I've checked the objects documentation available here:
https://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_additionalnumber.htm
It seems it does support an upsert call.

My code is below:
trigger UpdateCallCenter on User (after insert, after update, before delete) {
	if (Trigger.isAfter) {
		if (Trigger.isInsert || Trigger.isUpdate) {
			AdditionalNumber[] insertNumber = new List<AdditionalNumber>();

			for (User u : Trigger.new) {
				AdditionalNumber aN = new AdditionalNumber(Name = u.Name, Phone = u.Extension, CallCenterId = u.CallCenterId);
				insertNumber.add(aN);
			}
			
			upsert insertNumber;
		}
	}
}


Where am I going wrong here?

Many thanks!
Hello all,

I've had a problem accessing information from the Contact object, via a lookup in the Event object. WhoId can't seem to get Phone Numbers, Mobile Numbers, E-Mail addresses etc... Which I need.

I've managed to write the following which, based on the event ID, fetches the information I want.

List<Event> e1 = new List<Event>();
e1 = [SELECT Id, WhoId FROM Event WHERE Id ='00UD000000SyFMB'];
System.debug('@@@@@'+e1);

Set<id> WhoId = new Set<id>();
for(event e2 : e1) {
    whoId.add(e2.whoId);
}

List<Contact> c = [SELECT Name, Phone, Email FROM Contact WHERE Id IN : WhoId];
System.debug('@@@@@'+c);
Running this as an anonymous script returns the data I want, I'm just having trouble articulating it into a wrapper script so I can call information from 2 objects on the same row.

Hopefully I've explained my problem well enough!

Thank you!

Hello,

I'm trying to perform a simple Upsert operation with a trigger on the AdditionalNumber object (related to the Call Center stuff).

However, I'm getting the error message:
DML not allowed on AdditionalNumber

I've checked the objects documentation available here:
https://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_additionalnumber.htm
It seems it does support an upsert call.

My code is below:
trigger UpdateCallCenter on User (after insert, after update, before delete) {
	if (Trigger.isAfter) {
		if (Trigger.isInsert || Trigger.isUpdate) {
			AdditionalNumber[] insertNumber = new List<AdditionalNumber>();

			for (User u : Trigger.new) {
				AdditionalNumber aN = new AdditionalNumber(Name = u.Name, Phone = u.Extension, CallCenterId = u.CallCenterId);
				insertNumber.add(aN);
			}
			
			upsert insertNumber;
		}
	}
}


Where am I going wrong here?

Many thanks!
Hello all,

I've had a problem accessing information from the Contact object, via a lookup in the Event object. WhoId can't seem to get Phone Numbers, Mobile Numbers, E-Mail addresses etc... Which I need.

I've managed to write the following which, based on the event ID, fetches the information I want.

List<Event> e1 = new List<Event>();
e1 = [SELECT Id, WhoId FROM Event WHERE Id ='00UD000000SyFMB'];
System.debug('@@@@@'+e1);

Set<id> WhoId = new Set<id>();
for(event e2 : e1) {
    whoId.add(e2.whoId);
}

List<Contact> c = [SELECT Name, Phone, Email FROM Contact WHERE Id IN : WhoId];
System.debug('@@@@@'+c);
Running this as an anonymous script returns the data I want, I'm just having trouble articulating it into a wrapper script so I can call information from 2 objects on the same row.

Hopefully I've explained my problem well enough!

Thank you!