1
logObj.MC_LineNumber__c = err.getLineNumber();  

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

2 Answers 2

4

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.

2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .