Visualforce Error
System.StringException: Invalid id: Sean Broker Team
Class.FileUploadOpp.ReadFile: line 33, column 1
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Hi All,
wonder if anyone can help me out with a problem that i have when inserting a .CSV through Visualforce to opportunity... i have a Lookup field : -
o.BrokerSalesAgent__c = inputvalues[4];
which need to link an custom object which contains existing records that i want to link to via the name of the record. I have managed to link this through by using the record ID on the .csv but i have a 3rd party that will not have access to record ID's.
when try to use the name of the record i get the following error message: -
System.StringException: Invalid id: Sean Broker Team
Class.FileUploadOpp.ReadFile: line 33, column 1
I know that i have to write some code to search for the existing records (ID,Name) but not sure how to approach this?
the code below shows the inputvalues from my .csv file mapping them to the fields in the opportunity object.
rowCount = 0;
filelines = nameFile.split('\n');
opptoupload = new List<Opportunity>();
for (Integer i=1;i<filelines.size();i++)
{
String[] inputvalues = new String[]{};
inputvalues = filelines[i].split(',');
rowCount = filelines.size() -1;
Opportunity o = new Opportunity();
o.RecordTypeId = inputvalues[0];
o.Broker_Ref__c = inputvalues[1];
o.Name = inputvalues[2];
o.StageName = inputvalues[3];
o.BrokerSalesAgent__c = inputvalues[4];
o.AccountId = inputvalues[5];
o.CloseDate = date.valueof(inputvalues[6]);
opptoupload.add(o);
}
Can anyone point me in the right direction or help me with a example of how i can do this please?
thanks,
sean.
When I had to do it, I looped through csv file lines, added record name to a set. using the set, did a SOQL to build a map <Id,Name>, then finally built records using namemap.get(inputvalue[4]). I oversimplified, but you get the point.
Saraag
Hi Saraag,
do you have an example that you can send me?
thanks,
sean.
Code was working the last time I checked. I had a csv file with casenumber,notes,relatedcasenumber as input. I had to find the Ids for casenumber and internalcasenumber and then close them. Please excuse any errors.
Saraag