You need to sign in to do that
Don't have an account?

Apex Trigger Connection User
Hi,
How do I fire trigger only when a record is created by Connection User in salesforce to salesforce integration. i.e. We have SF2SF integration and a trigger updates certain lookup fields but I want to fire that trigger only when a record is created by connection user. I tried CreatedById = '[Id of the connection user] ' but that did not work. Please assist.
Thanks
UT
How do I fire trigger only when a record is created by Connection User in salesforce to salesforce integration. i.e. We have SF2SF integration and a trigger updates certain lookup fields but I want to fire that trigger only when a record is created by connection user. I tried CreatedById = '[Id of the connection user] ' but that did not work. Please assist.
Thanks
UT
is there any way to identify the user if that is connection user ? if yes then let the trigger fire but you proceed the trigger only for connection users...
Thanks,
Sandeep
can you paste your code here..
you can simply check if user is 'connection user' then only it should proceed further else not...
----
trigger UpdateLookup on Manager__c (before insert, before update) {
try {
set<string> rtset = new set<string>();
for (Manager__c inq : trigger.new) {
rtset.add(inq.Record_Type__c);
}
Map<string,id> nameidmap = new Map<string,id>();
for(RecordType rt :[Select id,DeveloperName from RecordType Where DeveloperName in :rtset]){
for(string str :rtset ){
if(rt.DeveloperName==str){
nameidmap.put(str,rt.id);
}
}
}
for (Manager__c inq : trigger.new) {
if(inq.CreatedById=='005A0000001E5rmIAC'){
inq.RecordTypeId= nameidmap.get(inq.Record_Type__c);
}
}
} catch(Exception e) {
}
}
You can create a formula field on Manager object , which will check if createdBy.username is 'Connection user' then it will return true else false..
use formula like this: if( CreatedBy.Username == 'c', true, false)
now when your trigger fires that time you can simply check if this formula field is true then you can collect that record else not..and then you can perform your opertaion on all manager objects where this field is true..
Please implement this and let me know if this solves your issue..
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Thanks,
Sandeep
Salesforce Certified Developer