Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

SIL - Copy links from parent

Błażej O_
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.
August 13, 2013

Hello.

I'm struggling with a weird problem with SIL custom field.

What I'm trying to do is to copy links from parent right away on creation of subtask. However the tricky part is I want to copy only the links to issues with creation date after some date set in the customfield.

Here is my code:

string[] mlinked_issues = linkedIssues(parent);
string mthis_key = key;
string mlink_key;
string mindex = size(mlinked_issues);

 
for(number i=0; i<=mindex; i=i+1)
{
    mlink_key = mlinked_issues[i];
    logPrint("ERROR", "KEY: " + mlink_key + "--------- if(" + %mlink_key%.created + " >= " + %mthis_key%.customfield_10900 + ");");
    if (%mlink_key%.created >= %mthis_key%.customfield_10900)
    {
        logPrint("ERROR", "I'm inside IF statement!");
        linkIssue(key, mlink_key, "Relates");
    }
}

What is weird about it: earlier I have had the script without "if" statement and it worked perfectly copying ALL links from parent. Now, when I added "if" statement, it is still copying all links even though it is NOT entering the "if" statement. I even removed completely the "linkIssue" command... and it still copy all links from parent. Don't ask me how, I am completely confused.

Logs show that it shouldn't enter the "if" statement as well as some errors:

2013-08-14 17:26:55,034 ajp-bio-8009-exec-3 ERROR ***user_login*** 1046x30461x1 3uqcia ***user_IP*** /browse/ITEM-709 [commons.sil.routines.LogPrintRoutine] KEY: DOK-792--------- if(2013-08-07 14:01:00 >= 2013-08-14 17:13:40);
2013-08-14 17:26:55,040 ajp-bio-8009-exec-3 ERROR ***user_login*** 1046x30461x1 3uqcia ***user_IP*** /browse/ITEM-709 [commons.sil.routines.LogPrintRoutine] KEY: DOK-793--------- if(2013-08-12 14:09:51 >= 2013-08-14 17:13:40);
2013-08-14 17:26:55,047 ajp-bio-8009-exec-3 ERROR ***user_login*** 1046x30461x1 3uqcia ***user_IP*** /browse/ITEM-709 [commons.sil.routines.LogPrintRoutine] KEY: DOK-795--------- if(2013-08-14 11:46:51 >= 2013-08-14 17:13:40);
2013-08-14 17:26:55,053 ajp-bio-8009-exec-3 ERROR ***user_login*** 1046x30461x1 3uqcia ***user_IP*** /browse/ITEM-709 [commons.sil.routines.LogPrintRoutine] KEY: DOK-796--------- if(2013-08-14 11:47:04 >= 2013-08-14 17:13:40);
2013-08-14 17:26:55,059 ajp-bio-8009-exec-3 ERROR ***user_login*** 1046x30461x1 3uqcia ***user_IP*** /browse/ITEM-709 [commons.sil.routines.LogPrintRoutine] KEY: DOK-797--------- if(2013-08-14 11:47:14 >= 2013-08-14 17:13:40);
2013-08-14 17:26:55,064 ajp-bio-8009-exec-3 ERROR ***user_login*** 1046x30461x1 3uqcia ***user_IP*** /browse/ITEM-709 [jira.commons.ivm.IssueVariable] Variable >>.created<< is not a custom field.
2013-08-14 17:26:55,064 ajp-bio-8009-exec-3 ERROR ***user_login*** 1046x30461x1 3uqcia ***user_IP*** /browse/ITEM-709 [jira.commons.sil.SILUtils] [SIL Error on line: 10, column: 63] Variable >>.created<< is not a custom field.
2013-08-14 17:26:55,064 ajp-bio-8009-exec-3 ERROR ***user_login*** 1046x30461x1 3uqcia ***user_IP*** /browse/ITEM-709 [jira.commons.silrunner.UnifiedSilRunner] Exception while executing SIL program >>SilScript custom field Default Configuration for SIL - Kopiowanie linkow<<
com.keplerrominfo.jira.commons.sil.SILInfoException: [SIL Error on line: 10, column: 63] Variable >>.created<< is not a custom field.
(...)
Caused by: com.keplerrominfo.jira.commons.sil.SILException: Variable >>.created<< is not a custom field.
(...)
2013-08-14 17:26:55,067 ajp-bio-8009-exec-3 ERROR ***user_login*** 1046x30461x1 3uqcia ***user_IP*** /browse/ITEM-709 [plugins.keplercf.silscriptcf.SilScriptCFType] Exception occurred while executing SIL Script for custom field Default Configuration for SIL - Kopiowanie linkow on issue ITEM-709
com.keplerrominfo.jira.commons.sil.SILException: Exception while executing SIL program >>SilScript custom field Default Configuration for SIL - Kopiowanie linkow<<
(...)
Caused by: com.keplerrominfo.jira.commons.sil.SILInfoException: [SIL Error on line: 10, column: 63] Variable >>.created<< is not a custom field.
(...)
Caused by: com.keplerrominfo.jira.commons.sil.SILException: Variable >>.created<< is not a custom field.
(...)

I will appreciate any help on this issue. I'm quite new to using SIL, and probably I'm making some newbie mistakes, yet I can't find them for more than 6 hours already...

3 answers

1 accepted

2 votes
Answer accepted
Florin Manaila
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.
August 18, 2013

Hi,

It's the for condition that is wrong. It should be i < mindex instead of <=. The <= will do an extra iteration on a null element and that's the one that fails. It still creates the issue links because it works ok until the last iteration when it fails.

Błażej O_
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.
May 20, 2014

That's exactly what was wrong, thanks!
Sorry for such late acceptance of the answer.

0 votes
Alexandru_Iacob
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.
September 1, 2014

Hi Isaac,

You should add a SIL post-function on the Create Issue transition with your SIL code and publish the workflow.

You should add your code inside an if block, to execute only for subtasks:

if(!isNull(parent)) { ... }

Kind Regards,

Alex

0 votes
Isaac Savage
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 31, 2014

Hi Blaze,

I want to do this, minus the part about the dates. How do I create a field to which I can assign this code? I'm just wanting to copy the parent-issue's Confluence links down to the sub-tasks upon creation.

Thanks!

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, mindful member, mindful member badge, atlassian community, community kudos, community giveaway, atlassian swag, community values, empathy and kindness, badge challenge, atlassian learning, community engagement, swag giveaway

Earn a Badge, Win a Prize 🎁

Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!

Start here
AUG Leaders

Atlassian Community Events