I have written some code to auto-close incident after 5 days in Remedyforce. But I am getting error shown below.


Initial term of field expression must be a concrete SObject : List


Date d=System.today();
List<BMCServiceDesk__Incident__c> resolvedIncident = [ SELECT Id FROM BMCServiceDesk__Incident__c WHERE 
BMCServiceDesk__Status_ID__c = 'RESOLVED' AND
DAY_ONLY(BMCRF_Resolved_Date__c) < =: d ];

List<BMCServiceDesk__Status__c> closedStatusID = [ SELECT id FROM BMCServiceDesk__Status__c WHERE name = 'CLOSED' ];

List<BMCServiceDesk__Incident__c> l = new List<BMCServiceDesk__Incident__c>();
for(List<BMCServiceDesk__Incident__c> updateResolvedIncident : resolvedIncident)
      updateResolvedIncident.BMCServiceDesk__FKStatus__c = closedStatusID.id; // error line
update l;
  • May I know how to check and where check for the condition for todays date and resolved for 5 days. Apr 21, 2017 at 11:45
  • Questions about the logic itself are an entirely separate issue. Please stick to one question per question.
    – Adrian Larson
    Apr 21, 2017 at 12:10
  • ok.. Error : Initial term of field expression must be a concrete SObject : List got solved but now I want to check for 5 days how check? Please suggest. Apr 21, 2017 at 13:06
  • Please ask a separate question if you are facing a separate issue.
    – Adrian Larson
    Apr 21, 2017 at 13:27

2 Answers 2


The problem is, you're treating closedStatusId like it's a single record, but it's not. It's a List. Note that the List<SObject> type does not have any property named Id, so when you try to call closedStatusId.Id, you are bound to hit an error. It is unclear how exactly you should fix this error, but one option would be to get the first individual record from the list. If you only expect/need one result, you should add a LIMIT 1 clause to your query:

List<StatusObject__c> closedStatuses = [SELECT Id FROM StatusObject__c WHERE ... LIMIT 1];
if (closedStatuses.isEmpty()) return;

Id closedStatusId = closedStatuses[0].Id;
for (IncidentObject__c record : records)
    record.StatusLookup__c = closedStatusId;
    // add to update collection

If workflow doesn't work you could also go down the route of a scheduled apex class, something similar to what I've written below may help.

I've had problems with the Remedyforce Closed status value not updating the SLA clock, related to the Salesforce order of execution i believe? I'm presuming that's why you're going down the programmatic route rather than using a declarative workflow rule?

You can schedule the class to run once a day. If you need any further help I will try, but I'm not a developer, likewise if anybody else can see how to improve my code, feel free, I shan't be offended!

global class Set_Status_Closed_Scheduled  Implements Schedulable // If an Incident has in a static Resolved state for 30 days, change it to Closed
global void execute (SchedulableContext sc)
public void changeStatusToClosed()
    // Get Status ID for the ‘Closed’      
    List<BMCServiceDesk__Status__c> ClosedStatus = new List <BMCServiceDesk__Status__c>();

    ClosedStatus = [SELECT Id FROM BMCServiceDesk__Status__c WHERE Name = 'Closed'];

    List<BMCServiceDesk__Incident__c> listIncident = new List <BMCServiceDesk__Incident__c>();

    List<BMCServiceDesk__Incident__c> updateListIncident = new list <BMCServiceDesk__Incident__c>();

    // Define one more list of Incidents to be updated say ‘updatelistIncident’
    // Below query fetches records from 30 to 32 days. As per our discussion the incident should be closed
    //only after 30 days. So modify below filter logic.
    listIncident = [SELECT Id FROM BMCServiceDesk__Incident__c
                    WHERE (BMCServiceDesk__Status_ID__c = 'Resolved'
                           OR BMCServiceDesk__TemplateName__c = 'Incident Resolved')
                    AND BMCServiceDesk__FKRequestDefinition__c = ''
                    AND (BMCServiceDesk__StatusChangeDate__c = LAST_N_DAYS:0
                         OR BMCServiceDesk__StatusChangeDate__c = LAST_N_DAYS:31
                         OR BMCServiceDesk__StatusChangeDate__c = LAST_N_DAYS:32) LIMIT 100];
    for(BMCServiceDesk__Incident__c up: listIncident)
        // Below code line assign status id instead of status value    
        up.BMCServiceDesk__FKStatus__c = 'a4Bw0000000CcCNEA0';
        // Add to updatelistIncident list instead of current list below
    // change list name variable below
    update updateListIncident;


You must log in to answer this question.

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