KCF-Pro Access Field Input in SIL Data Source

I'm currently modifying a SIL Data Source for a custom field KCF - Multiple Autocomplete.

 

In many of the examples in the documentation (here for example KCFPRO/KCF Single Autocomplete) it shows argv["query"] and makes it sound like this should return the string of the user input in the field. I enabled logging and tested this out with some print statements. argv["query"] always returns an empty string for me. 

 

My SIL Data Source:

string[] issues = selectIssues("issuetype = Build");
string[] res;
for(string iss in issues){
    if(contains(iss.summary, argv["query"])){
        print("Made it inside of if: '" + argv["query"] + "'");
        res = addElementIfNotExist(res, iss);
    }
}
return res;

 

On my testing instance, I only have 5 issues of type Build. The script makes it inside of the if block all 5 times. This is because argv["query"] is the empty string. That means all of the Builds are returned from the script. However, the UI results are still restricted by the Issue Key & Summary. I was able to see this since only 1 of the Builds has an Issue Key from a project with a project key of DO. I entered DO into the field and only that 1 Build was displayed. It appears that something else is filtering down the results after the SIL Data Source.

 

Most importantly, I need to know how I can access the field input in my SIL Data Source.

Secondly, what else is filtering the results returned to the UI?

 

Example from documentation:

string [] issues = selectIssues("created < now()");
string [] res;
for (string iss in issues) {
    if (contains(iss.summary, argv["query"])) {
        res = addElementIfNotExist(res, iss);
    }
}
return res;

3 answers

1 accepted

Hi Andrew,

I have seen the message.
Actually, it seems like it wasn't clear to me neither (after trying your example, I though that there is a bug). After several researches and after I've consulted with my colleagues, it seems that, in order to get the argv["query"] right, you need to set the Filtering Strategy (from Autocomplete settings) to Datasource.

Message from the log:

Select Symptom Data Source Script.
---ARGV: 't'
Select Symptom Data Source Script.
---ARGV: 'ts'
Select Symptom Data Source Script.
---ARGV: 'tst-'
Select Symptom Data Source Script.
---ARGV: 'tst-11'

 

I'll change the video and add this as a note on the documentation as well.

 

Sorry for the mislead,

Alexandra

Thank you for working through this with me! Now it's working perfect :)

BTW, Kepler Custom Fields Pro has a great response time on the forums!

Hi Andrew,


I have just tested it on JIRA 7 with a PostgreSQL database and it works perfectly.

The only way to access what is right now in the current field is by using argv["query"]. This is also the way you filter the results in the UI (the list of options gets restricted when you type something in the input box).

 

However, if you say that in your case, argv["query"] returns an empty value, we may need some more details on it. 

 

Alexandra

When you say it works perfectly, where you able to verify that argv["query"] returned what was in your actual field input inside of your select script? Where I was testing: JIRA 6.4.6, DB MySQL, KCF Pro 1.0.2.

I'm not sure we're talking about the same thing this time. argv["query"] returns the input existing on the screen on edit time (what you type, at the moment you type). The select script gets triggered after the value typed is saved, so the argv["query"] should be null on this moment). If you want to get the value stored in the custom field in the select script, you should use Live Fields, from JJUPIN and use this syntax in the script: argv["customfield_id"].

Sorry, I meant to say SIL data source script (not select script).

@Alexandra Topoloaga Just wanted to make sure you were aware that I continued this thread on the answer I created here.

Alexandra, I watched the tutorial video that you created, thank you - I was doing what you showed in the video. However, my problem still persists.

 

With both a Single & Multi Autocomplete field, I set the option type to Issue. I then set the SIL Data Source to the following script:

 

print("Select Symptom Data Source Script.");
print("ARGV: '" + argv["query"] + "'");
return selectIssues("issuetype = Symptom");

 

I added the field to a screen and entered the text "testing". This is what was logged to catalina.out for both field types:

 

Select Symptom Data Source Script.
ARGV: ''

 

When testing both fields types - the results returned to the UI were still limited to having "testing" in the summary even though I didn't limit the options in the data source script based on argv["query"].

 

This indicates to me that your argv["query"] in your SIL Data Source script isn't the only thing that is limiting the options returned to the UI. This also verifies to me that argv["query"] isn't containing the field input string.

 

Can you please verify that when you print out your argv["query"] that the field input is actually printed out? Can you try to recreate the simple test that I did? Thank you for your help.

 

(My specs: JIRA 6.4.6, DB MySQL, KCF Pro 1.0.2.)

@Alexandra Topoloaga pinging you in case you don't get notified that I started this new thread - wanted to use a new answer since the amount of data I had to write.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

795 views 3 11
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you