You need to sign in to do that
Don't have an account?
![Praz Praz](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
System.StringException: Invalid id
I am passing this url
/apex/PosEntriesFilterPageExcel?id={!Account.Id}&soldBy={!utilityObject.soldBy__c}
and I am trying catch in the controller in the following way
String accountId=ApexPages.currentPage().getParameters().get('Id'); this.utilityObject.soldByValue__c=ApexPages.currentPage().getParameters().get('soldBy');
It is giving error in the second line
Yet I am receiving such exception. Any help will be appreciated
without fully knowing your object structure it's hard to say if this is right, but my guess would be that:
you are passing in the value of utilityObject.soldBy__c and trying to set it on utilityObject.soldByValue__c.
Do these two different fields hold references to the same Object Type? Once looks like it might be a userid and the other decimal maybe?
They are different instances in two different classes..ultityobject is being used for some utility purposes
The exception is pretty clear. You are trying to assign a string to an ID typed property so Apex attempts a conversion. If the conversion fails this exception is thrown.
What value is being returned by this statement in your code?
yeah it's a string value...can't we get any string or date type value in this?
Can't we send anything other than Id?
You can not assign an invalid ID to an ID field - either the primary key or a foreign key (relationship field). For example you can't set the AccountID field value on Contact to "Acme Corp" and expect the system to resolve it for you automatically.
If you want to establish a relationship with something that is not, in fact an ID (as it appears you want to do here) you have two choices:
In the case of the accountID example above if you had an external id field on account you could use something like "Acme Corp" to uniquely identify the related account without having to query for it.
If you're interested in exploring option 2, check out the API doc on the upsert operation here . And then the corresponding doc in the Apex Developer guide here.
Hope that helps.
While solving I found another peculiar problem
Here is the code I am passing as usual
Here I am receiving.. and printing in debug
ye the code is not going into this if logic or dynamic soql is getting malformed even though soldBy value is '' or null
If any of the passed id is null then one may get the above mentioned error.
just started learning coding .here is my coding .before update my custom customer object .I need to create new transaction record and assign the old customer name to transaction name and i have lookup relationship b/w them .I am getting below error .pls help me
Apex trigger updatecust caused an unexpected exception, contact your administrator: updatecust: execution of BeforeUpdate caused by: System.StringException: Invalid id: bibithaganesh: Trigger.updatecust: line 9, column 1
trigger updatecust on customer__c (before update) {
list<transaction__c> test=new list<transaction__c>();
list<customer__c> cust=new list<customer__c>();
for( customer__c c:trigger.old)
{
transaction__c t=new transaction__c();
t.name=c.name ;
t.customer__c=c.name;
test.add(t);
}
insert test;(do we need this line .. for before update?)
}