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

I need to use a string list to update multiple records, but only a single record is updating.
I need to use a string list to update multiple records, but only a single record is updating.
I have this to deserialize my incomng json:
public class person {
public String serviceID;
public String responseStatus;
public cls_equipmentList[] equipmentList;
}
class cls_equipmentList {
public String action;
public String receiverID;
public String location;
public String smartCardID;
public String leaseInd;
}
I can see my data with:
System.debug('DEBUG 3 ======== obj.equipmentList: ' + obj.equipmentList);
Which returns:
(cls_equipmentList:[
action=ADD, leaseInd=false, location=C, receiverID=R1270000274, smartCardID=S1270000274
],
cls_equipmentList:[
action=ADD, leaseInd=false, location=C, receiverID=R1270000264, smartCardID=S1270000264
])
Then I want to update each record in the equipmentList based on receiverID, but only the first record is updating.
I tired this:
if(obj.equipmentList[0].receiverID != null){
List<Equipment__c> allEQ = [SELECT Id, Name FROM Equipment__c WHERE Name = :obj.equipmentList[0].receiverID ];
for (Equipment__C currentEQ : allEQ) {
currentEQ.Action__c = 'Active';
}
update allEQ;
}
All help is appreciated.
I have this to deserialize my incomng json:
public class person {
public String serviceID;
public String responseStatus;
public cls_equipmentList[] equipmentList;
}
class cls_equipmentList {
public String action;
public String receiverID;
public String location;
public String smartCardID;
public String leaseInd;
}
I can see my data with:
System.debug('DEBUG 3 ======== obj.equipmentList: ' + obj.equipmentList);
Which returns:
(cls_equipmentList:[
action=ADD, leaseInd=false, location=C, receiverID=R1270000274, smartCardID=S1270000274
],
cls_equipmentList:[
action=ADD, leaseInd=false, location=C, receiverID=R1270000264, smartCardID=S1270000264
])
Then I want to update each record in the equipmentList based on receiverID, but only the first record is updating.
I tired this:
if(obj.equipmentList[0].receiverID != null){
List<Equipment__c> allEQ = [SELECT Id, Name FROM Equipment__c WHERE Name = :obj.equipmentList[0].receiverID ];
for (Equipment__C currentEQ : allEQ) {
currentEQ.Action__c = 'Active';
}
update allEQ;
}
All help is appreciated.
Please try once like below.I have not tested code you may get some syntactical errors.
Hope this helps you!
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
All Answers
Please try once like below.I have not tested code you may get some syntactical errors.
Hope this helps you!
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
Error: Compile Error: Variable does not exist: allEQ at line 12 column 38
Which is: " for(Equipment__c currentEQ : allEQ){ "
if(receverIds != null)
" and now it works fine...I have no idea why, but is works. It updates all the records in the cc.receverIds.
Thanks for your help.