Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

context variable null check

Hi Guys,
In my job i have a context variable as the I/p parameter, i wanna check if the user i/p for this context variable is null or not. If !null then the job should run as is. But in case it is null then the execution should not proceed & the tAssertcatcher(I am using this in my job due to certain req) should be invoked than in-turn does some task like logging the error.
Any suggestion of how to do this?
Regards,
Sam
Labels (2)
3 Replies
Anonymous
Not applicable
Author

Hi,
From your description, I think you need the "Run if " connection in your job.
Please see the related reference: Connection types. Could you mind giving us more information or elaborate your case with an example with input and expected output values so that we can help you to design a job.
Best regards
Sabrina
Anonymous
Not applicable
Author

Hi,
Sorry due to certain restrictions i can't share the exact use case, but we can think it as below.
1. The user gives a input for his name , say context.name
2. I need to check if its null, if null i need to call the Assert catcher. else it should not call the same. Basically this means we can't use a tAssert as it goes to tassertCatcher in both cases(success/failure i.e. null/!null).
Regards,
Sam
Anonymous
Not applicable
Author

Hi smaiti,
First of all, the two component tAssert and tAssertCatcher must be used together. That's true, tAssertCatcher always work regardless of the exppression on tAssert matches or not. If you want tAssertCatcher works only when the context variable is null, tAssertCatcher is not the best component for your requirement.
To me, you can use a tWarn to send a warn message base on a condition with RunIf connector, and use tLogcatcher to capture the warn message, the job design looks like:

....tjava-->Run if_1-->tWarn
-->Run if_2-->other processing...
tlogcatcher--main--->tlogrow

tJava:
If(context.name==null){
globalMap.put("isNull", true);
}else{
globalMap.put("isNull", false);
}
set the condition of runIf_1 as:
(Boolean)globalMap.get("isNull")
set the condition of runIf_2 as:
!(Boolean)globalMap.get("isNull")
In this job, tWarn component works only when the condition of RunIf link is true, that means the context variable is null.

Best regards
Sabrina