You need to sign in to do that
Don't have an account?
Trigger error
Hi All,
Please help me on bellow error
Error: Compile Error: Initial term of field expression must be a concrete SObject: List<New__c> at line 17 column 33
R_Type__c is picklist filed
trigger Updateallcases on Case (after insert) {
List<Case> updatedCases=new List<Case>();
List<RecordType> recType = [select id from RecordType where name = 'New Rec' AND sobjecttype = 'Case' AND IsActive = TRUE limit 1];
List<New__c> customSettingMap = New__c.getall().values();
if(!recType.isempty())
{
String RecordTypeAid = rectype[0].id;
for(case c : Trigger.new)
{
if(c.RecordTypeId == RecordTypeAid )
{
if(c.Comments__c == customSettingMap.External__c)
{
c.R_Type__c = customSettingMap.Case_Type__c;
updatedCases.add(c);
}
}
}
}
Update updatedCases;
}
Hi Vinni
I think the Problem here is you got the values of the customsetting .Instead you can get the map of those customsetting .
List<New__c> customSettingMap = New__c.getall().values();
The above list contains only the values in the New__c custom setting , but it won't know which value is for External__c and Case_Type__c in that list.
So You can go with getall() method to access all the key-value pair in the custom setting :
Map<String_dataset_name, CustomSettingName__c> mcs = CustomSettingName__c.getAll();
Kindly let me incase you need assistance on the above.
Thanks
Mariappan Perumal
Hi,
You have a customSetting(New__c) of List type of which you have extracted all the values in customSettingMap(This is a List) and you are comparing & assiging the values of one field against a list and this isn't possible. Please see the changes that I've made below. I'm assuming that
Your custom setting will have only one entry that matches to the above if condition.
Below is my code.
getting bellow error
Error: Compile Error: Invalid field R_Type__c for SObject New__c at line 18 column 33
Check if the API name of the field R_Type__c on Case object is correct and if the type matches that of Case_Type__c field on your custom settings, if the data type is different may be you need to cast it...Some thing like string.ValueOf(customSetting.Case_Type__c)
Hi,
Thanks for your help
The API Name is given correctly
Case_Request_Type__c is Text field and Request_Type__c is Picklist field
Error: Compile Error: Invalid field Case_Request_Type__c for SObject JPCCDefaultQueueForNoMatchKeyword__c at line 18 column 48
trigger Updateallcases on Case (after insert) { List<Case> updatedCases=new List<Case>(); List<RecordType> recType = [select id from RecordType where name = 'New Rec' AND sobjecttype = 'Case' AND IsActive = TRUE limit 1]; List<New__c> customSettingMap = New__c.getall().values(); if(!recType.isempty()) { String RecordTypeAid = rectype[0].id; for(case c : Trigger.new) { if(c.RecordTypeId == RecordTypeAid ) { for(New__c customSetting : customSettingMap) { if(c.Comments__c == customSetting.External__c) { c.R_Type__c = string.ValueOf(customSetting.Case_Type__c)
updatedCases.add(c); } } } } } Update updatedCases; }
HI,
Thanks four help
I am getting bellow error after changing my code
Error: Compile Error: Invalid type: String_dataset_name at line 6 column 7
trigger Updateallcases on Case (after insert) {
List<Case> updatedCases=new List<Case>();
List<RecordType> recType = [select id from RecordType where name = 'New Rec' AND sobjecttype = 'Case' AND IsActive = TRUE limit 1];
//List<New__c> customSettingMap = New__c.getall().values();
Map<String_dataset_name, New__c> customSettingMap = New__c.getAll();
if(!recType.isempty())
{
String RecordTypeAid = rectype[0].id;
for(case c : Trigger.new)
{
if(c.RecordTypeId == RecordTypeAid )
{
if(c.Comments__c == customSettingMap.External__c)
{
c.R_Type__c = customSettingMap.Case_Type__c;
updatedCases.add(c);
}
}
}
}
Update updatedCases;
}
Hi
Change the String_dataset_name to just String
Map<String_dataset_name, New__c> customSettingMap = New__c.getAll(); ------>
Map<String, New__c> customSettingMap = New__c.getAll();
Try to use and let me know incase it didnt resolve your issue.
Thanks
Mariappan Perumal