Script Runner Post Function Clone Issue



I'm trying to create a clone issue in another project using script.
this is my script

cfValues['Derivar Tarefa']?.value == 'Incident'

def cf1 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Catalogo de Servicios - LAM'}
issue.setCustomFieldValue(cf1, sourceIssue.getCustomFieldValue(cf1))
def cf2 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Aplicación LAM'}
issue.setCustomFieldValue(cf2, sourceIssue.getCustomFieldValue(cf2))
def cf3 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Servicio PIMS LAM'}
issue.setCustomFieldValue(cf3, sourceIssue.getCustomFieldValue(cf3))
def cf4 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Servicio Policy Tool'}
issue.setCustomFieldValue(cf4, sourceIssue.getCustomFieldValue(cf4))
def cf5 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Servicio GLI'}
issue.setCustomFieldValue(cf5, sourceIssue.getCustomFieldValue(cf5))
def cf6 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Servicio LogViewer'}
issue.setCustomFieldValue(cf6, sourceIssue.getCustomFieldValue(cf6))
def cf7 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Servicio Claim'}
issue.setCustomFieldValue(cf7, sourceIssue.getCustomFieldValue(cf7))
def cf8 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Servicio Batch Module'}
issue.setCustomFieldValue(cf8, sourceIssue.getCustomFieldValue(cf8))
def cf9 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Servicio PIMS Fixing'}
issue.setCustomFieldValue(cf9, sourceIssue.getCustomFieldValue(cf9))
def cf10 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Servicio PIMS Person'}
issue.setCustomFieldValue(cf10, sourceIssue.getCustomFieldValue(cf10))
def cf11 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Servicio PIMS Product'}
issue.setCustomFieldValue(cf11, sourceIssue.getCustomFieldValue(cf11))
def cf12 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Servicio Interfaz'}
issue.setCustomFieldValue(cf12, sourceIssue.getCustomFieldValue(cf12))
def cf13 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Servicio Vision'}
issue.setCustomFieldValue(cf13, sourceIssue.getCustomFieldValue(cf13))
def cf14 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Servicio Report Vision'}
issue.setCustomFieldValue(cf14, sourceIssue.getCustomFieldValue(cf14))
def cf15 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Servicio Sun System'}
issue.setCustomFieldValue(cf15, sourceIssue.getCustomFieldValue(cf15))
def cf16 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Servicio Jenkins LAM'}
issue.setCustomFieldValue(cf16, sourceIssue.getCustomFieldValue(cf16))
def cf17 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Servicio ODM LAM'}
issue.setCustomFieldValue(cf17, sourceIssue.getCustomFieldValue(cf17))
def cf18 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Affects Version/s'}
issue.setCustomFieldValue(cf18, sourceIssue.getCustomFieldValue(cf18))
def cf19 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Emergencia'}
issue.setCustomFieldValue(cf19, sourceIssue.getCustomFieldValue(cf19))
def cf20 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Impacto'}
issue.setCustomFieldValue(cf20, sourceIssue.getCustomFieldValue(cf20))
def cf21 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Ambiente LAM'}
issue.setCustomFieldValue(cf21, sourceIssue.getCustomFieldValue(cf21))
def cf22 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Comportamento esperado'}
issue.setCustomFieldValue(cf22, sourceIssue.getCustomFieldValue(cf22))
def cf23 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Comportamento com erro'}
issue.setCustomFieldValue(cf23, sourceIssue.getCustomFieldValue(cf23))
def cf24 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Descrição passo-a-passo do erro'}
issue.setCustomFieldValue(cf24, sourceIssue.getCustomFieldValue(cf24))
def cf25 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Tipo de Atendimento'}
issue.setCustomFieldValue(cf25, sourceIssue.getCustomFieldValue(cf25))

and i receive this message in log


2017-08-11 16:51:31,619 http-nio-8080-exec-29 ERROR b54037 1011x2651005x1 1rtofso, /secure/CommentAssignIssue.jspa [c.o.s.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: ALSD-12, actionId: 501, file: null
    at com.atlassian.jira.issue.IssueImpl.getCustomFieldValue(
    at com.atlassian.jira.issue.Issue$getCustomFieldValue$ Source)





1 answer

0 votes

Hello Valeria.

Those are a lot of customFields that you seem to be setting. Sadly for you, one of those is failing to give you the proper reference as you can see:

 "at com.atlassian.jira.issue.IssueImpl.getCustomFieldValue("

This means that one of the customFields that you are getting is null. Let me explain:


In that line cf1 is null, because you have failed to properly get a reference to that object. That means that in one of your lines like this:

def cf10 = customFieldManager.getCustomFieldObjects(sourceIssue).find { == 'Servicio PIMS Person'}

The "find" operation is returning null.

Do you understand what I mean?

You need to run each one of the lines "def cf" in the script console untill you see which one gives you null. Then you will know which line of your script you need to fix.

I hope this helps.



Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Marketplace Apps

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,687 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