function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sfadm sfadmsfadm sfadm 

Allow Process Builder to Save Process With No Immediate Action

Hello,

What I need to achieve is explained in the image of my process builder.

Process Builder Fake Action

I need a dump or fake action of not doing anything when the first condition is met.

Becauser there is no standard way in Salesforce to allow the process builder to save process with NO immediate action I used the following apex class.
 
public class ReturnNull_Class {
  @InvocableMethod(label='Return null' description='Returns null for use in Process Builder.')
  public static List<String> returnNull(){
    return null;
  }
}
The issue I have is with the test class.

It does not cover the code in my ReturnNull_Class.

Here is the implementation of the Test Class:
@isTest
private class ReturnNull_Test {
    static testmethod void returnNullTest(){
        ReturnNull_Class.returnNull();
    }
}
Please andvise as well as please share an example of a test class which can help me achieve sufficient code coverage in the ReturnNull_Class?
 
Best Answer chosen by sfadm sfadm
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

I trust you are doing very well.

Your test class is absolutely fine. I have checked in my org and it is working fine. It is covering the class. Please try to run the test again.

Also, it is an idea (https://success.salesforce.com/ideaView?id=08730000000sXtlAAE) to 'Allow Process Builder to Save Process With No Immediate Action'. You can check the Jared Jones solution/workaround on that idea, which says:
Use an update record action, and set the criteria for updating records to the option "Updated records meet all conditions".  Then set a condition that will never be true.  For example, Account Name = "Condition designed to never be true".

It is much easier than creating an apex class and it's test class.

You can also refer to the below blogs which might help you further.

https://ericsplayground.wordpress.com/2016/11/10/how-to-tell-process-builder-to-do-nothing/

https://automationchampion.com/2018/04/10/getting-started-with-process-builder-part-86-what-create-a-process-with-no-action-really/

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in future.

Thanks and Regards,
Khan Anas

All Answers

sfadm sfadmsfadm sfadm
The test class ReturnNull_Test is covering 0 percentage of my ReturnNull_Class.

Please advise how to increse the code coverage?
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

I trust you are doing very well.

Your test class is absolutely fine. I have checked in my org and it is working fine. It is covering the class. Please try to run the test again.

Also, it is an idea (https://success.salesforce.com/ideaView?id=08730000000sXtlAAE) to 'Allow Process Builder to Save Process With No Immediate Action'. You can check the Jared Jones solution/workaround on that idea, which says:
Use an update record action, and set the criteria for updating records to the option "Updated records meet all conditions".  Then set a condition that will never be true.  For example, Account Name = "Condition designed to never be true".

It is much easier than creating an apex class and it's test class.

You can also refer to the below blogs which might help you further.

https://ericsplayground.wordpress.com/2016/11/10/how-to-tell-process-builder-to-do-nothing/

https://automationchampion.com/2018/04/10/getting-started-with-process-builder-part-86-what-create-a-process-with-no-action-really/

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in future.

Thanks and Regards,
Khan Anas
This was selected as the best answer