Need to update the value or increment the value in sequence field in below code snippet as follows :
// Loop through each of the incoming task and add them to the new request
whTasks.eachWithIndex { task, idx ->
// idx = idx + 1
oWHTaskNode.@ws_no = task[1].ws_no
log.info (" IC : Incoming WT - " + oWHTaskNode.@ws_no)
oWHTaskNode.@itemno = task[1].itemno
log.info (" IC : Incoming Item - " + oWHTaskNode.@itemno)
)
oWHTaskNode.@lot_number = task[1].lot_number
log.info (" CT WT : LNO = " + oWHTaskNode.@lot_number)
oWHTaskNode.@itemno = task[1].itemno
log.info (" CT WT : INO = " + oWHTaskNode.@itemno)
oWHTaskNode.@sequence = "1"
log.info (" CT WT : SEQ = " + oWHTaskNode.@sequence)
//Since we already have one WHTask node in the Default request, we replace it with the first WHTask from incoming request
// Later, other WHTasks will be added in the default request
if(idx == 0){
// First task, therefore replace the WHTask in Default (New) request with this
//oRequestNew.Body.WarehouseOrderConfirmation.WHOrder.WHTask.replaceNode{ oWHTaskNode }
//Direct replacement of node is not working, so removing the node by replacing with EMPTY and then adding a new node ;-)
oRequestNew.Body.InductionConfirmation.CO.FP.WS.replaceNode{}
oRequestNew.Body.InductionConfirmation.CO.FP.appendNode( oWHTaskNode )
}else {
// Subsequent WHTasks will be added as a new node in the Default (New) request
oRequestNew.Body.InductionConfirmation.CO.FP.appendNode( oWHTaskNode )
}
oWHTaskNode = new XmlSlurper().parseText(whTaskNodeStr)
}
Hi @Tia
Do you need a custom filed with. auto increment of a number with every new issue (task) is created?
if so you can try this, this need a script runner plugin
Create a text custom field (single line). In the example I added "Numbers" as field name. Then create a postfuntion with the script below.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.search.SearchProvider
// get all the used numbers so far
def query = ComponentAccessor.getComponent(JqlQueryParser).parseQuery("project = JA AND 'Numbers' is not EMPTY ORDER BY 'Numbers' DESC")
def results = ComponentAccessor.getComponent(SearchProvider).search(query,ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(),new PagerFilter(1))
int maxNumbers = 0
CustomField cField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Numbers")
// get the highest used number
for(Issue documentIssue: results.getIssues())
{ maxNumbers = documentIssue.getCustomFieldValue(cField) as Integer }
// set the new number
def newNumbers = ++maxNumbers as String
issue.setCustomFieldValue(cField, newNumbers)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am inserting the above code in the post function under custom script and getting these 2 error. Please can you help @Sid
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.