You need to sign in to do that
Don't have an account?
Method does not exist or incorrect signature error. Assistance appreciated
Greetings All,
I am receiving the error mentioned above when trying to compile a trigger. Actually, the error in its entirety is Method does not exist or incorret signature:[MAP:String, String].put(SOBJECT:Request__c) at line 40 column 34.
There is probably a pretty simple solution to this, but being new to apex, it isn't readily apparent to me. Any assistane is geatly appreciated.
Here is the code:
trigger UpdateSimilarRequests on Request__c (after update) { //list will contain a concatenation of the custodian and subject List<String> subjCustList = new List<String>(); //map will contain a concatenation of the custodian and subject //but will also include the MRC Record Type Map<String, String> subjCustToRecordType = new Map<String, String>(); for(Request__c reqNew : Trigger.new) { Request__c reqOld = Trigger.oldMap.get(reqNew.Id); //if the old record type is Additional AND the old record status is not 02-Approved AND the new record status is 02-Approved if(reqOld.RecordTypeId == '01270000000Dvwh' && reqOld.Status__c != '02-Approved' && reqNew.Status__c == '02-Approved') { //add the values to the list subjCustList.add(String.valueOf(reqNew.Custodian_Lookup__c) + String.valueOf(reqNew.Subject__c)); //add the values to the map subjCustToRecordType.put(String.valueOf(reqNew.Custodian_Lookup__c) + String.valueOf(reqNew.Subject__c), reqNew.Record_Type__c); } } if(subjCustList.size() > 0) { //find the requests to update for(Request__c r : [SELECT Status__c, Custodian_Lookup__c, Client_Directive__c FROM Request__c WHERE Custodian_and_Subject__c IN : subjCustToRecordType AND isEligibleForSimilarRequestUpdate__c = 'TRUE' ]) { if(subjCustToRecordType.containsKey(r.Custodian_and_Subject__c)&& r.Record_Type__c != subjCustToRecordType.get(r.Record_Type__c)){ r.Status__c='02-Approved'; subjCustToRecordType.put(r); } } } if(subjCustList.size() > 0){ //update the requests Update subjCustList; } }
The line referenced in the error is the line tht is:
subjCustToRecordType.put(r);
Thanks
Hello Cobra1212;
The map "subjCustToRecordType" is a <String, String> map.
It means the "key" and "value" both should be strings.
You can insert a value to the map by using the "put(String, String)" method.
At line 40, you are trying to insert a sObject to the map by using the "put(String, String)" method incorrectly.
You can't insert a sObject to a <String, String> map.
See the "Map Methods" section in Apex Code Developer's Guide
I see you have used the "put(String, String)" method correctly in a previous line.
So I think this could be just a mistake.
:)