1

I need to call a flow, to create or update an sObject, in my REST class :

@RestResource(urlMapping='/object')
  global with sharing class RESTObject{
    RestRequest req = RestContext.request;
    String eventId = req.params.get('eventId');
    Event ev;

    if(eventId == null){
      //some code here
    }
    else{
      ev = [SELECT Id, Obj_Id__c FROM Event WHERE Id=:eventId];
      if(ev.Obj_Id__c == null){
            Map<String, Object> params = new Map<String, Object>();
            params.put('EventId', eventId);

            Flow.Interview.CreateEventE flow = new Flow.Interview.CreateEventE(params);
            flow.start();

            String comId = (String) flow.getVariableValue('comId');

            try {
                update new Commande__c(Id = comId , RecordTypeId = rt.Id);
            } catch (DMLException e) {
                //System.debug('#### ' + e);
                return null;
            }
            return ev.Obj_Id__c;
    }
    else{ 
       //some code here
    }
}

When I try this in the workbench, using the Id of an event with a null Obj_Id__c, I get an error at the line flow.start(); and at the line with the update.

How can I fix that ?

EDIT

The error is:

System.FlowException : An unhandled error occurred in this flow An unhandled error occurred while processing the flow.

And it indicates me the line with the start().

I also get a mail each time I try to run the flow that give me the

INSERT --- INSERT FAILED --- ERRORS : (FIELD_FILTER_VALIDATION_EXCEPTION)

EDIT 2 : after remove the filter on my field enter image description here

  • Is this a part of your class? Does it work with out a method? – Saumya Ranjan Satapathy May 31 '16 at 13:05
  • 2
    Please paste the error that you are getting. – Saumya Ranjan Satapathy May 31 '16 at 13:06
  • @Saumya Ranjan Satapathy I edited my question – dou May 31 '16 at 13:31
2

FIELD_FILTER_VALIDATION_EXCEPTION clearly suggests that in your flow there is a failure in the insertion of record due to Validations on the field .This may be due to a lookup filters on one of the fields of record your flow is trying to insert .

Verify that flow is receiving all the parameters and field values it needs for proper functioning .

  • There is a filter on a object, I disable it to try and there is no longer error, but when I run the url on workbench, I get "Transfer-Encoding: chunked" and it don't return what I expected (ev.Obj_Id__c which is "null" in my case) is that normal ? – dou May 31 '16 at 15:25
  • Hi @Mohith Shrivastava I have updated my question to add the picture of what I get – dou Jun 1 '16 at 7:20
  • 1
    You are getting 200 Status code which means your service is running now .dig through logs to see variable values .Hope that helps – Mohith Shrivastava Jun 1 '16 at 8:45
  • Ok thanks @Mohith Shrivastava ! I also have another question : if I want to test a null value : eventId = null when I try this url "/services/apexrest/object" in the workbench it thows me an error "System.NullPointerException: Attempt to de-reference a null object" but the point is to test a null object... I don't see how test that case – dou Jun 1 '16 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.