Hello Community,
I am a total beginner in the field of scripting and am faced with a simple task.
We are using JSM on DC with Insight. The Insight is still under construction. There we already have an area "Software" with the objects of the individual product names, which we let fill by a DB query. As attributes we have among others Softwarename (ID: 445), Displayname (ID: 447) & SoftwareNr (ID: 446).
We have included the "Insight-DropDown-SingleSelect" field in the SW Screen in Jira.
Now we want that when selecting the software in the Jira-dropdownfield, the correct software is found within insight environment and then the value of the attribute "SoftwareNR" (ID: 446) is output.
Oh, we use the app Scriptrunner (v7.9), through which the following groovy script was included:
###### SNIPPET ######
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.component.ComponentAccessor
// from this point: https://community.atlassian.com/t5/Marketplace-Apps-Integrations/How-to-get-Insight-attribute-ID-in-post-function-by-Name-through/qaq-p/1178027#M59839
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.CustomFieldManager;
import java.sql.Timestamp;
import java.text.DateFormat
import java.util.Date
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade
import com.riadalabs.jira.plugins.insight.services.model.factory.ObjectAttributeBeanFactory
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeAttributeFacade
@WithPlugin("com.riadalabs.jira.plugins.insight")
@PluginModule ObjectAttributeBeanFactory objectAttributeBeanFactory
@PluginModule ObjectFacade objectFacade
@PluginModule ObjectTypeAttributeFacade objectTypeAttributeFacade
def insightObjects = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_12801")) //output '[ xxx (CTEST-123456)]'
def obj = insightObjects[0] //output 'xxx (CTEST-123456)'
def obj2 = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_12801")).toString().split("\\(")[0].trim().substring(1) // Contains the plain text string
//obj.objectAttributeBeans.find {objectTypeAttributeFacade.loadObjectTypeAttributeBean(it.objectTypeAttributeId).name == "SoftwareNR"}
def test = obj.objectAttributeBeans.find {objectTypeAttributeFacade.loadObjectTypeAttributeBean(446) == "${insightObjects}"}
def test2 = obj.objectAttributeBeans.find {objectTypeAttributeFacade.loadObjectTypeAttributeBean(it.objectTypeAttributeId).name == "SoftwareNR"}
def test3 = obj.objectAttributeBeans
//until this point: https://community.atlassian.com/t5/Marketplace-Apps-Integrations/How-to-get-Insight-attribute-ID-in-post-function-by-Name-through/qaq-p/1178027#M59839
def clientName = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_12706")) //user device
def jobName = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_12801")).toString().split("\\(")[0].trim().substring(1) //passes the name of the software to powershell
def file = new File("C:\\temp\\logging.txt")
file.write("insightobject ${insightObjects}\nWithout corner bracket: ${obj}\nWithout corner bracket - plain text: ${obj2}\n446-Output: ${test}\n2446-Out: ${test2}\nAttributBeans: ${test3}\n")
def pb = new ProcessBuilder("powershell.exe", "-File", "C:\\Program Files\\Atlassian\\Application Data\\Jira\\scripts\\push_software-to-client.ps1", clientName, jobName)
pb.redirectErrorStream(true)
def proc = pb.start()
proc.waitFor()
###### END SNIPPET #######
I am grateful for any kind of help and have now already spent some hours/ well rather some restless nights trying to find the solution.
But I keep getting confused. Sorry, I am not a programmer :-(
And yes, I have searched and read a lot and not correctly understood what the problem is.
Troubleshooting, I just help myself with the output to the txt.file.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.