You need to sign in to do that
Don't have an account?
Ravi G 9
I am facing challenging while maping some fields from batch
I have custom object Invoice__c and which is having lookup of account on Invoice_Number__c.
- Account recordtype is payment and requirement is like whenever this Payment recordtype account is not having any parent account then this Invoice_Number__c ParentId will be blank too.
- If this Payment recordtype account have parent record then this should be map into this Invoice_Number__c parentId.
I am trying to implement like this and It is failing and getting null exception.
if(accRec.ParentId != null ){ inv.Invoice_Number__r.parentId = accRec.ParentId; }Pls check this and help me on this. Thanks!!
You can modify your code as follows to achieve this functionality:
This code first checks if the Account's record type is "Payment" and it has no parent account. If that's the case, then it sets the parent Id of the Invoice_Number__c to null.
If the Payment record type account has a parent account, then it maps the parent account's Id to the Invoice_Number__c's ParentId.
Make sure to replace "DeveloperName" with the actual Developer Name of your Record Type. Also, ensure that the API names of your custom objects and fields are correct.
If you find this answer helpful, Please mark it as the best answer.
Hi Sunil, check this code: