Problem inserting a table into customfield

Hellow,

We need to insert a table to customfield in Jira (Jira 5.2.8, jeditor 1.5.47), the isert should be initiated by pushing a button.But when the button is pushed no content is transfered to the field.Please see the code:

</br>

<script type="text/javascript" language="javascript">

function addSTDTable() {

jeditorSetData("customfield_10501", jeditorGetData("customfield_10501") + '<p dir="rtl">&nbsp;</p>', {format : 'raw'});

jeditorSetData("customfield_10501", jeditorGetData("customfield_10501") + '<div dir="rtl" align="right">', {format : 'raw'});

jeditorSetData("customfield_10501", jeditorGetData("customfield_10501") + '<table dir="rtl" border="1" cellspacing="0" cellpadding="0" align="right"><tbody><tr><td colspan="5"><p dir="rtl" align="center">&nbsp;</p></td></tr><tr><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;תנאי מוקדם</p></td><td><p dir="rtl">מהות הבדיקה&nbsp;</p></td><td><p dir="rtl">&nbsp;תוצאה צפויה</p></td><td><p dir="rtl">Pass/Fail - תוצאה בפועל (ב- STR בלבד)&nbsp;</p></td></tr><tr><td><p dir="rtl">1</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td></tr><tr><td><p dir="rtl">2</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td></tr><tr><td><p dir="rtl">3</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td></tr><tr><td><p dir="rtl">4</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td></tr><tr><td><p dir="rtl">5</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td></tr><tr><td><p dir="rtl">6</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td></tr><tr><td><p dir="rtl">7</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td></tr><tr><td><p dir="rtl">8</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td></tr><tr><td><p dir="rtl">9</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td></tr><tr><td><p dir="rtl">10</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td><td><p dir="rtl">&nbsp;</p></td></tr></tbody></table></div>', {format : 'raw'});

jeditorSetData("customfield_10501", jeditorGetData("customfield_10501") + '<p><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /></p>', {format : 'raw'});

}

</script>

<input id="AddSTDTable" type="button" value="STD הוסף תבנית" onclick="addSTDTable();" />

</br>

</br>

<script type="text/javascript" language="javascript" src="http://www.xxx/globalScripts/DM_JscriptPointers.asp">

</script>

<script>

function addDM2STD() {

var From1;

var To1;

var From2;

var To2;

var MyLink;

var res;

res = SearchDocs(0);

MyLink = res;

From1 = MyLink.indexOf('DOCNUMBER');

To1 = MyLink.indexOf('/DOCNUMBER');

From2 = MyLink.indexOf('NAME');

To2 = MyLink.indexOf('/NAME');

if (To1 > 0) {

//tinyMCE.get(document.getElementsByName("customfield_10501")[0].id).setContent(tinyMCE.get(document.getElementsByName("customfield_10501")[0].id).getContent({format : 'raw'}) + '<div style="text-align: right; direction: rtl; "><a href="http://www.xxxx/opendocsdocument/default.aspx?Library=RAFDOCS&DocNumber=' + MyLink.substring(From1 + 10, To1 - 1) + '&DocName=' + MyLink.substring(From2 + 14, To2 - 4) + '&NotCloseWindow=true&MatanDocName=RAF_' + MyLink.substring(From1 + 10, To1 - 1) + '" target="_blank">' + MyLink.substring(From2 + 14, To2 - 4) + '</a></br></div>', {format : 'raw'});

jeditorSetData("customfield_10501", jeditorGetData("customfield_10501") + '<div style="text-align: right; direction: rtl; "><a href="http://www.xxxx/opendocsdocument/default.aspx?Library=RAFDOCS&DocNumber=' + MyLink.substring(From1 + 10, To1 - 1) + '&DocName=' + MyLink.substring(From2 + 14, To2 - 4) + '&NotCloseWindow=true&MatanDocName=RAF_' + MyLink.substring(From1 + 10, To1 - 1) + '" target="_blank">' + MyLink.substring(From2 + 14, To2 - 4) + '</a></br></div>', {format : 'raw'});

}

}

</script>

<input id="AddDM2STD" type="button" value="Attach DM To STD" onclick="addDM2STD();" />

text

</br>

</br>

With Best regards,

Slava

2 answers

1 accepted

Hi,

The problem was solved by placing the second function before the first.

Hi Slava,

The code is correct, it works for me:

You may need to check the following:

1. Customfield id is 10501

2. function addSTDTable is defined when you click the button

3. Browser console log

4. This shouldn't affect but try to remove third arg here: jeditorSetData("customfield_10501", jeditorGetData("customfield_10501") + '<p dir="rtl">&nbsp;</p>', {format : 'raw'});

It should be like this: jeditorSetData("customfield_10501", jeditorGetData("customfield_10501") + '<p dir="rtl">&nbsp;</p>');

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
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

134 views 0 3
Join discussion

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