Notes
Notes - notes.io |
<import>
<DataChange public-id="bc:AssociateMultipleTroubleTickets">
<ExternalReference>Associate_Multiple_TroubleTickets_With_Policies</ExternalReference>
<Description>Associate multiple TroubleTickets with their respective policies</Description>
<Status>OPEN</Status>
<Script><![CDATA[
uses gw.api.database.Query
uses gw.api.database.Relop
uses gw.transaction.Transaction
var resultWriter = DataChange.util.ResultWriter
resultWriter.append("== Associate Multiple TroubleTickets with Policies Data Change started ==n")
// ===== SIMPLE LIST FORMAT =====
var associations = {
// Format: [TroubleTicketPublicID, PolicyNumber, TermNumber]
["bc:262102", "MOTN0000044180", 1],
["bc:262103", "MOTN0000044181", 1],
["bc:262104", "MOTN0000044182", 1],
["bc:262105", "MOTN0000044183", 1]
// Add more associations in the same format
}
// ==============================
try {
var processed = 0
var succeeded = 0
var failed = 0
resultWriter.append("Processing ${associations.Count} associationsnn")
// Process each association
associations.each( association -> {
processed++
var troubleTicketPublicID = association[0] as String
var policyNumber = association[1] as String
var termNumber = association[2] as Integer
resultWriter.append("${processed}. Processing Ticket ${troubleTicketPublicID} -> Policy ${policyNumber} Term ${termNumber}n")
try {
// Get PolicyPeriod
var policyPeriod = PolicyPeriod.finder.findByPolicyNumberAndTerm(policyNumber, termNumber)?.LatestPolicyPeriod
if (policyPeriod == null) {
resultWriter.append(" !! ERROR: PolicyPeriod not found for ${policyNumber} term ${termNumber}n")
failed++
return
}
// Get TroubleTicket by PublicID
var troubleTicket = Query.make(TroubleTicket)
.compare(TroubleTicket#PublicID, Relop.Equals, troubleTicketPublicID)
.select()
.AtMostOneRow
if (troubleTicket == null) {
resultWriter.append(" !! ERROR: TroubleTicket with PublicID ${troubleTicketPublicID} not foundn")
failed++
return
}
resultWriter.append(" - Found TroubleTicket: ${troubleTicket.TroubleTicketNumber}n")
resultWriter.append(" - Found Policy: ${policyPeriod.PolicyNumber}n")
// Process association
Transaction.runWithNewBundle( bundle -> {
troubleTicket = bundle.add(troubleTicket)
var policy = bundle.add(policyPeriod.Policy)
var troubleTicketHelper = new CreateTroubleTicketHelper(bundle)
troubleTicketHelper.linkTroubleTicketWithPolicy(troubleTicket, policy)
troubleTicketHelper.linkTroubleTicketWithAccount(troubleTicket, policy.Account)
resultWriter.append(" ✓ Linked to Policy: ${policy.PolicyNumber}n")
resultWriter.append(" ✓ Linked to Account: ${policy.Account.AccountNumber}n")
}, User.util.UnrestrictedUser)
resultWriter.append(" ✓ SUCCESS: Association completedn")
succeeded++
} catch (e: Exception) {
resultWriter.append(" !! ERROR: ${e.Message}n")
failed++
}
resultWriter.append("n")
})
// Summary Report
resultWriter.append("="*60 + "n")
resultWriter.append("PROCESSING SUMMARY:n")
resultWriter.append("="*60 + "n")
resultWriter.append("Total associations to process: ${associations.Count}n")
resultWriter.append("Successfully processed: ${succeeded}n")
resultWriter.append("Failed: ${failed}n")
resultWriter.append("="*60 + "n")
if (failed == 0) {
resultWriter.append("🎉 ALL ASSOCIATIONS COMPLETED SUCCESSFULLY!n")
} else if (succeeded == 0) {
resultWriter.append("❌ ALL ASSOCIATIONS FAILED - PLEASE CHECK ERRORSn")
} else {
resultWriter.append("⚠️ SOME ASSOCIATIONS FAILED - CHECK ERRORS ABOVEn")
}
resultWriter.append("="*60 + "n")
} catch (e: Exception) {
resultWriter.append("!! GLOBAL ERROR: ${e.Message}n")
resultWriter.append("!! StackTrace: ${e.StackTraceAsString}n")
}
resultWriter.append("== Data Change completed ==n")
]]></Script>
</DataChange>
</import> easy to share with others. Click here ...
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team
