Pass empty string if variable does not exist... reply - VisualCron - Forum

Community forum

thomas
2017-03-29T21:04:33Z
Hi Sam

I'm not able to answer posts in FAQ-troubleshooting, so I had to start a new thread 😕 . It's a reply to this post:

Quote:


I have a common Visual Cron job that is called by other jobs. I'd like to have a variable which *some* of the jobs will pass in, but others will omit. The problem is that for the jobs where this variable is not defined, its passing in an error message, "Job Variable 'Recipients' not found." rather than an empty string or null. Is there any way to change this behavior?

Background:
We have a custom notification used by all our jobs. I'd sometimes like to pass in custom recipients, however, when you select a notification it doesn't allow you to specify variables for them. So instead, I modified the notification itself to look for a job variable called "Recipients". The problem is I don't want to define this job variable on every single one of our jobs, I only want to define it on the jobs that need custom recipients.

Thanks for any help.



I hope they add variables to notifications soon (really really want it!), until then here is an INCREDIBLY dirty workaround:

If the job variable 'Recipients' is not passed to the notification, you know you will instead get the text 'Job Variable 'Recipients' not found.'
That means you can do a string replace, where you replace this exact string with an empty string, like this:

{STRING(Replace,{JOB(Active|Variable|Recipients)},Job Variable 'Recipients' not found.,)}

So where you previously had {JOB(Active|Variable|Recipients)}, swap it out with the formula above.

It's not at all pretty, but I think it works...

Thomas
Scroll to Top