Vote count:
0
I have a question, I hope I can tell you clearly my problem.
Regarding the parentfunction at the account, I added two fields to the account ParentID (15) and ParentIDLong (18). The ParentID field is a formulafield with the code below.
IF(LEN(Parent.Id) < 1, Id,
IF(LEN(Parent.Parent.Id) < 1, (Parent.Id),
IF(LEN(Parent.Parent.Parent.Id) < 1, (Parent.Parent.Id),
IF(LEN(Parent.Parent.Parent.Parent.Id) < 1, (Parent.Parent.Parent.Id),
IF(LEN(Parent.Parent.Parent.Parent.Parent.Id) < 1, (Parent.Parent.Parent.Parent.Id),
IF(LEN(Parent.Parent.Parent.Parent.Parent.Parent.Id) < 1, (Parent.Parent.Parent.Parent.Parent.Id),
IF(LEN(Parent.Parent.Parent.Parent.Parent.Parent.Parent.Id) < 1, (Parent.Parent.Parent.Parent.Parent.Parent.Id),
IF(LEN(Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Id) < 1,(Parent.Parent.Parent.Parent.Parent.Parent.Parent.Id),">7"))))))))
Now I need the ParentLongID, unfortunately its not possible to change the formula, because I will get an error which is "the formula is too big".
I wrote a trigger which posted the long ID into the field ParentLongID (code below).
Trigger SetParentIDLong on Account (before update) {
FOR (Account Acc : Trigger.new) {
Account oldAcc = Trigger.oldMap.get(Acc.Id);
String idStr = Acc.ParentID__c;
Id idVal = idStr;
idStr = idVal;
If (oldAcc.ParentId__c != Acc.ParentID__c) {
Acc.ParentIdLong__c = idStr;
}
So far so good, it works if I create the hierarchy from the top to the bottom.
Example:
MotherCompany ParentIDLong: blank
Daughter1 ParentIDLong: 001b000000XUTQAAA5
Daughter2 ParnetIDLong: 001b000000XUTQAAA5
But if I add a MotherMotherCompany
Example:
MotherMotherCompany ParentIDLong: blank
MotherCompany ParentIDLong: 001m000000Ft35yAAB
Daughter1 ParentIDLong: 001b000000XUTQAAA5
Daughter2 ParnetIDLong: 001b000000XUTQAAA5
The trigger doesn't work, because the trigger changed only the ParentIDLong at the Mothercompany.
Its possible to change with trigger all other companies as well?
Thanks, Sascha
Salesforce Parent ID Trigger
Aucun commentaire:
Enregistrer un commentaire