3

I am relatively new to Visual Workflow, and just trying to wrap my brain around some things... what is an empty string, and how is this different from "is null?"

Specifically, I am trying to write decision elements that check whether a field from a Record Lookup is blank... if it's blank, the flow skips on, if not, I'll have another step. I tried using "is null" for the operator in a decision outcome, but I need something in the Value... do I use GlobalConstant.True? Or should I be doing this another way, ie. equals EmptyString, or even equals and leave the Value blank?

Just looking for a little clarity...

Thank you!

3

Update:

Since you are using Workflow, you can use the functions listed on the following page:

http://www.salesforce.com/us/developer/docs/pages/Content/pages_variables_functions.htm

Try using the ISBLANK function: pass any field into it, and if it is NULL or empty (""), i.e. has LENGTH = 0, the function will result to true, else it yields false.


EDIT : This answer is for Apex, not Workflow.

You can use comparison operators or a nifty String instance method

Examples:

string t1='';
string t2=null;
string t3='i am not blank';    

// so you can see the results
if(t1==null)
    system.debug('t1 is null');
else
    system.debug('t1 is not null');
system.assertEquals(false,t1==null);

// so you can see the results
if(t2==null)
    system.debug('t2 is null');
else
    system.debug('t2 is not null');
system.assertEquals(true,t2==null);

// try this nifty string method
system.debug('t1 = "'+t1+'" -- String.isBlank(t1) = '+string.valueOf(String.isBlank(t1)));
system.assertEquals(true,String.isBlank(t1));

system.debug('t2 = "'+t2+'" -- String.isBlank(t2) = '+string.valueOf(String.isBlank(t2)));
system.assertEquals(true,String.isBlank(t2));

system.debug('t3 = "'+t3+'" -- String.isBlank(t3) = '+string.valueOf(String.isBlank(t3)));
system.assertEquals(false,String.isBlank(t1));

See here for String Instance Methods.

1

You can have the Decision defined as field equals blank. In otherwords, have the Variable that you place the field value you attempted to retrieve on the left hand side, equals for the operator and leave the right hand side empty.

0

This answer relates to Flows (Create >> Workflows & Approvals >> Flows).

I had a similar issue where I needed to display a text field value from an sObject variable.

To determine if a value is null, you will need to use a decision element with two outcomes. Generally the following is suggested:

outcome1: {!variable.field__c} is null {!$GlobalConstant.True}
outcome2: {!variable.field__c} is null {!$GlobalConstant.False}

However, this did not correctly perform a null check on either text or date fields. Instead, the 'was set' operator worked for me:

outcome1: {!variable.field__c} was set {!$GlobalConstant.True}
outcome2: {!variable.field__c} was set {!$GlobalConstant.False}

Hopefully this helps someone else as well.

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.