You need to sign in to do that
Don't have an account?
Filipe Baradelli
Invalid id value for this SObject type: a0B36000002Hn66EAC
This error appeared and point to the line 200. I don't know why the id value is not being valid for the object.
listaproduto=[SELECT Items__c,Total_Cost__c,Account__c,Id,(SELECT Id,Product__c,Product_Short_Description__c,Product_Price__c,Product_Name__c,Quantity__c,VF_Image__c FROM Catalog_Line_Items__r) FROM Catalog_Order__c WHERE Status__c = 'Cart' AND CreatedById =:UserInfo.getUserId() ORDER BY LastModifiedDate DESC NULLS FIRST LIMIT 1]; for(Catalog_Order__c ctlgOrdr : listaproduto){ for(Catalog_Line_Item__c ctlgLineItem : ctlgOrdr.Catalog_Line_Items__r){ System.debug(ctlgLineItem.Product__c); produto2.Id = ctlgLineItem.Id; // LINE 200 produto2.Name = ctlgLineItem.Product_Name__c; produto2.Description = ctlgLineItem.Product_Short_Description__c; produto2.isActive = true; } }
Hi Filipe,
In Salesforce the "Id" field is a system generated field and we are not allowed to assign any value for this field. The id is automatically generated when the record is inserted in the system and after that we cannot change this.
If you have any lookup field of "Catalog_Line_Item__c" object in your produto2 object then you can simply use the below statement :
produto2.Catalog_Line_Item__c = ctlgLineItem.Id;(Catalog_Line_Item__c is the API name of lookup field)
Please let me know if you need more information or help on this.
Thanks,
Abhishek Bansal
The produto2 is a Product2 and doesn't have the Catalog_Line_Item__c field. This part of the code is to get the product's data and pass to produto2 (public), which will allow me take this product and add it to a newly created Opportunity.
Here is my full code if you want to see :
Thanks.
Hi Filipe,
As I already told you that we are not allowed to assign any value to Id field in salesforce so you have to comment out the line no. 200.
I am not aware of your current requirement but you cannot assign any value to Id field so you have to remove this line.
Thanks,
Abhishek Bansal
This error points to line 393, column 1: insert stdPriceBookEntry;
The field Product__c is reference type and I didn't find a field from Product2 to accept the Product__c data (if it is the problem).
What I need to do in this case (I'm sorry if you've told me and I'm asking again)?
Hi Filipe,
I am not completely sure but you can try with the below statement :
produto2.Product__c= ctlgLineItem.Product__c;
Thanks,
Abhishek
Product__c is a field from Catalog_Line_Item__c so I can't assign it to produto2 (Product2).
Hi Filipe,
You can remove this line and as i already told you that i am not aware of your data structure so i can't help you much here.
If you want then you can contact me on Skype or Gmail.
Gmail : abhibansal2790@gmail.com
Skype : abhishek.bansal2790
Thanks,
Abhishek Bansal