My requirement is I have to create 2 new fields on Lead object 'IsTopLevelAccount__c'
(Checkbox field) and 'Parent__c '
(Lookup field on account).
I map 'IsTopLevelAccount__c'
of lead with 'IsTopLevelAccount__c'
of account using standard mapping and via apex trigger I map 'Parent__c ' with the standard field 'Parent'
of the account which is parent account field.
There is an existing validation on the account object as follow:
OR(AND(
$User.BypassValidation__c = FALSE,
OR(
ISPICKVAL( ProposedAccountType__c , "Customer" ),
ISPICKVAL( ProposedAccountType__c , "" )
),
IsTopLevelAccount__c = FALSE,
(ISBLANK( Parent.Id ))
),
AND(
$User.BypassValidation__c = FALSE,
OR(
ISPICKVAL( ProposedAccountType__c , "Customer" ),
ISPICKVAL( ProposedAccountType__c , "" )
),
IsTopLevelAccount__c = TRUE,
NOT((ISBLANK( Parent.Id )))
)
)
This validation checks during the account creation,either I mark as a top level account for this I set IsTopLevelAccount__c = TRUE
or I can add the parent account.
On lead object I have created 'Parent__c '
field which is a lookup field and as I can not map lookup field with the standard account field,so I user trigger on account object(afterUpdate) which maps 'Parent__c'
with 'Parent'
which is standrd field of account as I mentioned already.
This validation is working fine on Account object but when in lead conversion when I select an account in 'Parent__c'
field the it always throw me the validation error even if I provide the value in Parent__c.In logs I found that it always gives me Parent.Id as null not sure why?
but weird thing is if I user ISNULL(Parent.Id)
then validation is pass during the lead conversion but on the account object it throws the validation error again not sure why?
This is the weird behavior and I am nopt getting any clue how to solve this.I tried to use OR((ISBLANK( Parent.Id ),(ISNULL( Parent.Id ))
but still it is not working.
Can anybody suggest why this is happening??