I am facing the error **
"A problem with the OnClick JavaScript for this button or link was encountered: {faultcode:'MALFORMED_ID', faultstring:'malformed id {Assessment__c.Id}', }
** " on clicking a custom Submit button on Assessment__c object. My purpose is, after clicking that submit button for a particular user profile the record will be opened using a read non-editable record type. Kindly advice.
Java Script code on Button Click
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
sforce.connection.sessionId = "{!$Api.Session_ID}";
sforce.apex.execute("FinalAssesmentClass","submitMethod",{asID:'{Assessment__c.Id}'});
Controller :
global class FinalAssesmentClass{
webservice static asResult submitMethod(ID asID){
asResult res = new asResult();
Assessment__c o=new Assessment__c(Id=asID);
String usrProfileName = [select u.Profile.Name from User u where u.id = :Userinfo.getUserId()].Profile.Id;
If(usrProfileName =='00eU0000000daQg')
{
o.RecordTypeId='012J00000008pwl';// Read only Record type
}
else
{
o.RecordTypeId='01IU0000000brV9'; //Normal record type
}
res.assId= asID;
system.debug(res);
return res;
}
global class asResult {
webservice String errorMsg;
webservice Id assId;
}
}