You need to sign in to do that
Don't have an account?
Oleg Ishchuk
Failed deployment due to Metadata.Operation.retrieve
Hello, everyone! I have following part of code:
When I validate code during deployment I get errors. Errors are - 'System.ListException: List index out of bounds: 0' on line 77. When I try to use this code using an anonymous block, the accountLayout gets the first component. But during deployment, it seems like Metadata.Layout isn't visible. How can I solve this issue?
When I validate code during deployment I get errors. Errors are - 'System.ListException: List index out of bounds: 0' on line 77. When I try to use this code using an anonymous block, the accountLayout gets the first component. But during deployment, it seems like Metadata.Layout isn't visible. How can I solve this issue?
Salesforce have an official document regarding this error "System.ListException: List index out of bounds: 0"
https://help.salesforce.com/articleView?id=000329067&type=1&mode=1
If you need further suggestions to go through the below blogs,
https://salesforce.stackexchange.com/questions/13670/solve-system-listexception-list-index-out-of-bounds-0
https://developer.salesforce.com/forums/?id=906F000000092gOIAQ
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks.
do you add custom metadata type layout in the deployment package? Or has it already on the destination org?
No, I have no custom metadata type.
I have several page layouts. Metadata.Operation.retrieve gets a specific layout which I specify in LAYOUT_NAME constant. You can see it in the code above. But it is not custom metadata, it is standard metadata. And when I test this code in sandbox, everything is properly. But during deployment, I have an error. I resolved this issue using Test.isRunningTest. But it is not a good solution.