Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
brandk
Contributor III
Contributor III

Handling field names with spaces in ODAG script

Good day I am developing on demand apps. I have used the binding script below in my Template/Detailed app. My problem is that there are certain field names with spaces for example the field "Client ID " in the script below.  When I try run  the app I get "Unexpected token error". THE script works fine when I use other field names with no spaces.Unfortunately I cannot change this field name  because it is linked to other systems and it would require those systems to be changed too. Could anyone please assist. 

 

 

//Creates a WHERE statement which can be used in table loads to restrict the data to a smaller set

SUB ExtendWhere(Name, ValVarName)
LET T = Name & '_COLNAME';
LET ColName = $(T);
LET Values = $(ValVarName);
IF len(Values) > 0 THEN
IF len(WHERE_PART) > 0 THEN //If WHERE clause exists then extend it with further values
LET WHERE_PART = '$(WHERE_PART) AND MATCH($(ColName),$(Values))';
ELSE
LET WHERE_PART = ' WHERE MATCH($(ColName),$(Values))'; //If WHERE clause does not exist then create it
ENDIF
ENDIF
END SUB;

//Here we set the variables ready to hold the names of any fields we want considering for ODAG filtering (selection)
SET Sel_Implementation = ;      //resets the variable from any previous reload
SET Sel_Implementation = $(od_Implementation);   // follow 'ods_' with the field name as it appears in your UI / final load
SET Sel_Implementation_COLNAME ='Implementation'; // enter the field name as it appears in the source data

SET Sel_Client ID= ;
SET Sel_Client ID= $(od_Client ID);
SET Sel_Client ID_COLNAME =Client ID;

SET WHERE_PART = '';

//This section builds the WHERE_PART variables that are passed to the SUB
//It extracts the values that have been selected from each field

FOR EACH fldname IN 'Sel_Implementation', 'Sel_Client ID'
LET vallist = $(fldname);
WHEN (IsNull(vallist)) LET vallist = '';
IF len(vallist) > 0 THEN
CALL ExtendWhere('$(fldname)','$(vallist)');
ENDIF
NEXT fldname

//Evaluate the WHERE_PART variable in the script for debugging
TRACE Generated WHERE clause: ;
TRACE $(WHERE_PART);

@sunny_talwar
Labels (1)
1 Solution

Accepted Solutions
Brett_Bleess
Former Employee
Former Employee

See the following post for solution:

https://community.qlik.com/t5/Qlik-Sense-App-Development/Handling-field-names-with-spaces-in-ODAG-sc...

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.

View solution in original post

2 Replies
Brett_Bleess
Former Employee
Former Employee

I have reached out to product management to see if they can have a look at this post, not sure how long it may take them to get to it though.  I checked defect system, but I could not really find anything that fit, so we will have to wait to see if the PM knows something on this.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
Brett_Bleess
Former Employee
Former Employee

See the following post for solution:

https://community.qlik.com/t5/Qlik-Sense-App-Development/Handling-field-names-with-spaces-in-ODAG-sc...

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.