You need to sign in to do that
Don't have an account?

complier error in string assignment.
Hi,
i am trying to assign a string value to text type custom field on line 7 but getting the complier error "Expression cannot be assigned "
any idea what i am missing?
thanks,
ublic class IRPTemplateSelection { public PageReference TemplateSelection() { // String TemplateId = 'a0JP0000001qGwU'; String TemplateId = System.currentPageReference().getParameters().get('Templateid'); Orphan__c.Biodata_Report_Template_4_Conductor__c = TemplateId ; PageReference pageRef = new PageReference('https://cs4.salesforce.com/a0A?fcf=00B20000005raAO' ); pageRef.setRedirect(true); return pageRef; } }
Can you try with
String TemplateId = Apexpages.currentPage().getParameters().get('Templateid');
All Answers
Hi,
Check what value are you getting in TemplateId
My guess is you are not getting the values in there
Can you try with
String TemplateId = Apexpages.currentPage().getParameters().get('Templateid');
HI Crmtech21,
thanks it error is now gone.
but my custom field is still not being updated. it has no value in it. how i can update it ???
Biodata_Report_Template_4_Conductor__c is text field.
thanks
You are assigning value to the custom field "Biodata_Report_Template_4_Conductor__c" but not performing any DML operations like insert/update.
By viewing your below code
line1 Orphan__c MyOrp = new Orphan__c();
String TemplateId = Apexpages.currentPage().getParameters().get('Templateid');
if (TemplateId != '')
{myorp.Biodata_Report_Template_4_Conductor__c = TemplateId;}
else
{myorp.Biodata_Report_Template_4_Conductor__c = 'a0JP0000001qGwU';}
//you need to put some dml operation here
insert myorp;
P.S. I believe you want to update the myorp.. so you need to get the record which you want to update. The statement at line1 will always create a new instance.
If you are passing the orphan id using query string parameters as well you can do the update using below code
String oprId = Apexpages.currentPage().getParameters().get(‘id’); // id – key which having orp id
Orphan__c MyOrp = new Orphan__c(Id=orpId);
String TemplateId = Apexpages.currentPage().getParameters().get('Templateid');
if (TemplateId != '')
{myorp.Biodata_Report_Template_4_Conductor__c = TemplateId;}
else
{myorp.Biodata_Report_Template_4_Conductor__c = 'a0JP0000001qGwU';}
//you need to put some dml operation here
update myorp;
Let me know if this solves your query.