Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Edith1
Creator
Creator

Trigger Run If Java Condition - How to code not contains

Hello I am using this code for Trigger Run If to determine if the file format is .csv to run a component. ((String)globalMap.get("FileName")).contains(".csv")

How can I code for everything else? Is there a java code to check if Not Contains .csv?

Labels (2)
1 Solution

Accepted Solutions
cadap
Contributor III
Contributor III

Hi,

contains() returns a boolean type.

In you case, if the filename contains ".csv", the expression returns true.

If I understood you correctly, you want every other file than .csv, so all files, that do not contain ".csv"?

 

Simply type:

!((String)globalMap.get("FileName")).contains(".csv")

 

Notice the exclamation mark. It means "not".

 

View solution in original post

6 Replies
Anonymous
Not applicable

Hi

How does the file name come? Do you use a tFileList to iterate a folder? Can you please explain why you use the global available?

(String)globalMap.get("FileName")

 

Regards

Shong

vikramk
Creator II
Creator II

Hi Edith,

If you don't mind, could you share a snapshot of your job design which you are trying to achieve. It helps us to know the requirement.

Edith1
Creator
Creator
Author

Here's a screenshot of the job. In the beginning of the job, I'm iterating a temp table that includes the FileName to the tRestClient. The FileName has the file format of .csv or .xls. If the FileName contains .csv, then it goes to tFileRowCount and prints the message in tJavaFlex. If the FileName contains something else other than .csv, then I only want to print the message.

 

0693p000009pZryAAE.jpg

 

Anonymous
Not applicable

Hi

Thanks for sharing your job, it is clear now. To get the current value of FileName column, the expression is:

(String)globalMap.get("rowN.FileName")

rowN is the row identifier such as row1 before tFlowToIterate

The java code to check if Not Contains .csv is:

!((String)globalMap.get("rowN.FileName")).contains(".csv")

 

Regards

Shong

cadap
Contributor III
Contributor III

Hi,

contains() returns a boolean type.

In you case, if the filename contains ".csv", the expression returns true.

If I understood you correctly, you want every other file than .csv, so all files, that do not contain ".csv"?

 

Simply type:

!((String)globalMap.get("FileName")).contains(".csv")

 

Notice the exclamation mark. It means "not".

 

Edith1
Creator
Creator
Author

Thank you @Bernhard Gruber​ for your time and help!