You need to sign in to do that
Don't have an account?
Vigneshwaran Loganathan
Illegal assignment from Cycle_Plan_vod__c to Id
Hi Everyone,
I'm facing "Illegal assignment from Cycle_Plan_vod__c to Id". Below is my code,
I'm getting the values for colx from excel and should assign it to Cycle_plan_vod__c (Lookup in Cycle plan target) field. When i assign External id, I'm facing the error. I cant assign cyp.id as it returns null..!
Schema.sObjectType objectDefTar = Schema.getGlobalDescribe().get('Cycle_plan_Target_vod__c').getDescribe().getSObjectType();
sObject thisObjTar = objectDefTar.NewsObject();
if(cycPlanTargetFields.contains(headerNameTar) && headerNametar=='Cycle_Plan_vod__c')
{
system.debug('*****here' + headerNameTar);
Cycle_plan_vod__c cyp = new Cycle_plan_vod__c(External_ID_vod__c = colx);
thisObjTar.put(headerNameTar , cyp);
}
I'm facing "Illegal assignment from Cycle_Plan_vod__c to Id". Below is my code,
I'm getting the values for colx from excel and should assign it to Cycle_plan_vod__c (Lookup in Cycle plan target) field. When i assign External id, I'm facing the error. I cant assign cyp.id as it returns null..!
Schema.sObjectType objectDefTar = Schema.getGlobalDescribe().get('Cycle_plan_Target_vod__c').getDescribe().getSObjectType();
sObject thisObjTar = objectDefTar.NewsObject();
if(cycPlanTargetFields.contains(headerNameTar) && headerNametar=='Cycle_Plan_vod__c')
{
system.debug('*****here' + headerNameTar);
Cycle_plan_vod__c cyp = new Cycle_plan_vod__c(External_ID_vod__c = colx);
thisObjTar.put(headerNameTar , cyp);
}
Nayana K
Seems like you have to query records matching with external Id first so that you can get the SF record Id. Then assign.