You need to sign in to do that
Don't have an account?
RockyDrakeM
ERROR:Expression cannot be assigned
Hello,
I want to assign like line 3, i have error
thanks in advance
I want to assign like line 3, i have error
sObject sObj = new QuoteLineItem(); sObject s = new ContractLineItem(); s.get(fieldToCompare) = sObj.get(fieldToCompare); //ERROR:Expression cannot be assignedCan someone help me to achieve this use case ?
thanks in advance
Please try like below.
sObject sObj = new QuoteLineItem();
sObject s = new ContractLineItem();
// from your below line; what i understood is: you want to set value.
//s.get(fieldToCompare) = sObj.get(fieldToCompare);
s.put(fieldToCompare, sObj.get(fieldToCompare));
// if you want to compare
// Assumption 'fieldToCompare' type is String.
String contractLineItemVal = (String)s.get(fieldToCompare);
String quoteLineItemVal = (String)sObj.get(fieldToCompare);
if(contractLineItemVal.equalsIgnoreCase(quoteLineItemVal)){
// equals
}else{
//not equals
}
Regards,
Pawan Kumar
<pre>
sObject sObj = new QuoteLineItem();
sObject s = new ContractLineItem();
s.get(fieldToCompare) == sObj.get(fieldToCompare); //NOTE: "=="
</pre>
<pre>
sObject sObj = new QuoteLineItem();
sObject s = new ContractLineItem();
s.put(fieldToCompare, sObj.get(fieldToCompare); // copy one field value into another field
</pre>
<pre>
sObject sObj = new QuoteLineItem();
sObject s = new ContractLineItem();
s.put(fieldToCompare, sObj.get(fieldToCompare)); // copy one field value into another field
</pre>