You need to sign in to do that
Don't have an account?
GONZALO PIZARRO RIVERA 6
Map Error: System.StringException: Invalid id:
Hello, I am trying to get the User->Id field using a custom field (Id_SAP__c) that i have in the user object.
To do this i have created a map with those two fields in order to get the id of the user but i am receiving an error and i dont know how to solve it.
Please, can anyone help me?
This my code:
public static void fillOwnerField(List<Promoci_n__c> lstPromociones){
Set<String> setResources = new Set<String>();
for(Promoci_n__c p :lstPromociones){
if(p.Comercial_Id_SAP__c != null){
setResources.add(p.Comercial_Id_SAP__c);
}
}
System.debug('***setResources = '+setResources);
if(setResources.size() > 0){
Map<Id, User> mapSR = new Map<Id, User>([Select Id, Id_SAP__c From User where Id_SAP__c in: setResources]);
System.debug('***mapSR = '+mapSR);
for(Promoci_n__c p :lstPromociones){
System.debug('***p.Comercial_Id_SAP__c = '+p.Comercial_Id_SAP__c);
System.debug('***Comercial_Asignado__c = '+mapSR.values());
System.debug('***Comercial_Asignado__c = '+mapSR.get(p.Comercial_Id_SAP__c).Id_SAP__c);
p.Comercial_Asignado__c = mapSR.get(p.Comercial_Id_SAP__c).Id_SAP__c;
}
}
}
I get the error in line
System.debug('***Comercial_Asignado__c = '+mapSR.get(p.Comercial_Id_SAP__c).Id_SAP__c);
thank you in advance
To do this i have created a map with those two fields in order to get the id of the user but i am receiving an error and i dont know how to solve it.
Please, can anyone help me?
This my code:
public static void fillOwnerField(List<Promoci_n__c> lstPromociones){
Set<String> setResources = new Set<String>();
for(Promoci_n__c p :lstPromociones){
if(p.Comercial_Id_SAP__c != null){
setResources.add(p.Comercial_Id_SAP__c);
}
}
System.debug('***setResources = '+setResources);
if(setResources.size() > 0){
Map<Id, User> mapSR = new Map<Id, User>([Select Id, Id_SAP__c From User where Id_SAP__c in: setResources]);
System.debug('***mapSR = '+mapSR);
for(Promoci_n__c p :lstPromociones){
System.debug('***p.Comercial_Id_SAP__c = '+p.Comercial_Id_SAP__c);
System.debug('***Comercial_Asignado__c = '+mapSR.values());
System.debug('***Comercial_Asignado__c = '+mapSR.get(p.Comercial_Id_SAP__c).Id_SAP__c);
p.Comercial_Asignado__c = mapSR.get(p.Comercial_Id_SAP__c).Id_SAP__c;
}
}
}
I get the error in line
System.debug('***Comercial_Asignado__c = '+mapSR.get(p.Comercial_Id_SAP__c).Id_SAP__c);
thank you in advance
Please try the below code:
Thanks,
Maharajan.C
All Answers
Please try the below code:
Thanks,
Maharajan.C