KCF-Pro Access Field Input in SIL Data Source

AndrewB November 25, 2015

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

2 votes
Answer accepted
Alexandra Topoloaga
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 8, 2015

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

AndrewB December 8, 2015

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

AndrewB December 8, 2015

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

0 votes
AndrewB December 4, 2015

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.)

AndrewB December 4, 2015

@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.

0 votes
Alexandra Topoloaga
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 26, 2015

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

AndrewB December 1, 2015

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.

Alexandra Topoloaga
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 1, 2015

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"].

AndrewB December 2, 2015

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

Alexandra Topoloaga
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 2, 2015

Hi Andrew, Please check this link: https://confluence.kepler-rominfo.com/pages/viewpage.action?pageId=19989824 Thanks, Alexandra

AndrewB December 8, 2015

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events