Post

2 followers Follow
0
Avatar

pass a parameter to CZQL

I need to pass a parameter to a where clause in CZQL.
Example from the Home page I want to retrieve all projects for the current user, where Project Geo is equal to User Geo but I don't know how to pass to user geo in the where condition:
performQuery("select count() as cnt, C_ResourceAlignment from project where C_GeoPickList = {CurrentUser().C_Geo}

I tried to put it in a variable, but I don't know how to pass the variable the same.
Thanks 

Cristina Floris Answered

Official comment

Avatar

Hi Cristina,

Is this a custom page that you're building via Settings >> Configure?

Best regards,

Roland

Roland Pumputis
Comment actions Permalink

Please sign in to leave a comment.

7 comments

0
Avatar

Hi Roland, yes it is a custom page I created under Organization Object
Thanks,
Cristina

Cristina Floris 0 votes
Comment actions Permalink
0
Avatar

Hi Cristina,

You can pass the current user's C_Geo field value to your script like this:

I hope this helps.

Best regards,

Roland

Roland Pumputis 0 votes
Comment actions Permalink
0
Avatar

Hi,
sorry, another question, if I want to pass to the query (in the where clause) a value selected from a dropdown list? Is it possible?
Example:
<select id="myGeo">
<option value="WW">WW</option>
<option value="EMEA">Emea</option>
<option value="JAPAN">Japan</option>
</select>

performQuery("select count() as cnt, C_OverallProjectHealth from project where C_GeoPickList in( " + myGeo +") group by C_OverallProjectHealth");
What I have to insert in place of myGeo?
Thank you,
Cristina

Cristina Floris 0 votes
Comment actions Permalink
0
Avatar

Hi Cristina,

This is not a Clarizen-specific question. This is a JavaScript question. There's many ways of doing this. Here's a simple example:

HTML:

<select id="myGeo" onchange="valSelected()">
  <option value="WW">WW</option>
  <option value="EMEA">Emea</option>
  <option value="JAPAN">Japan</option>
</select>

JS:

let valSelected = () => {

  let myGeo = document.getElementById("myGeo").value;

  performQuery("select count() as cnt, C_OverallProjectHealth from project where C_GeoPickList in( " + myGeo +") group by C_OverallProjectHealth");

}

I hope this helps.

Roland

Roland Pumputis 0 votes
Comment actions Permalink
0
Avatar

Hi Roland,

thank you for your suggestion, I have resolved with JQuery:
$('#myGeo').change(function(){
var a =($(this).val());
performQuery("select count() as cnt, C_OverallProjectHealth from project where C_GeoPickList in( '" + a + "') group by C_OverallProjectHealth");
})

Cristina Floris 0 votes
Comment actions Permalink