logObj.MC_LineNumber__c = err.getLineNumber();  

Why is it showing an error like "Illegal assignment from Integer to String" ?


Make sure that destination field type is same as that of the value you are trying to put into it. If MC_LineNumber__c is of type string then use

logObj.MC_LineNumber__c = String.valueOf(err.getLineNumber());

Or else, specify return type of method getLineNumber() same as that of MC_LineNumber__c.


Try this:

logObj.MC_LineNumber__c = String.valueOf(err.getLineNumber());

EDIT It might also help to consider changing MC_LineNumber__c to a Number field if it's only ever going to contain numbers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.