0

i am trying to save some details in policy center. i am getting those details from billing center and immediately trying to save it but it is giving me exception.

i have called "issuePolicyPeriod" function of billingAPI and returned some values and i need to save this in Policy center.

Exception: Exception came while saving commision detais: java.lang.RuntimeException: com.guidewire.pl.system.exception.TransactionException: commitBundle must not be called in a transaction.

Code /** * Issue a policy period in Billing Center * @param period: the policy period * @param transactionID: the unique transaction id to make this call idempotent */

override function createPolicyPeriod(period: PolicyPeriod, transactionID : String) : String { var issuePolicyInfo = new IssuePolicyInfo() issuePolicyInfo.sync(period) PCLoggerCategory.BILLING_SYSTEM_PLUGIN.info("Sending policy ${period} to Billing System")

 var commissionList = callUpdate(\ b -> b.issuePolicyPeriod(issuePolicyInfo, transactionID))

gw.transaction.Transaction.runWithNewBundle(\ bundle -> {
  var commission = new CommissionDetails()
  bundle.add(commission)
  commission.Commission_SI = new BigDecimal( commissionList.get(1))
  commission.CommissionGST_SI = new BigDecimal(commissionList.get(2))
  commission.CommissionRate_SI = commissionList.get(3).toString()

})

return  commissionList.get(0)

}

I am calling issuePolicyPeriod() function from PC using BillingAPI and returning commission details from BC and trying to save it in PC entity immediately.

Hi, thank you for your answer. I tried the above code but it is not saving to entity and nor giving any exception. I have a doubt here will current bundle still available? because here we are calling billing center and don't know when BC responds. in web service calls will guidewire hold the current bundle until response comes back? When guidewire commits the current bundle in web service calls?

2 Answers2

1

Try to use the current transaction instead of create new.

var commissionList = callUpdate(\ b -> b.issuePolicyPeriod(issuePolicyInfo, transactionID))

var bundle = gw.transaction.Transaction.Current
var commission = new CommissionDetails(bundle)
commission.Commission_SI = new BigDecimal( commissionList.get(1))
commission.CommissionGST_SI = new BigDecimal(commissionList.get(2))
commission.CommissionRate_SI = commissionList.get(3).toString()

return  commissionList.get(0)

When you use runWithNewBundle, after block execution ends bundle.commit() it's called

Carlos Duque
  • 482
  • 3
  • 7
0

I had a similar error with a bundle (java.lang.RuntimeException: com.guidewire.pl.system.exception.TransactionException: commitBundle must not be called in a transaction) and I could be solved with this steps

  1. quit or comment this: gw.transaction.Transaction.runWithNewBundle(\ bundle -> {})

  2. The problem was that I had an existing bundle, so I only needed to call it with getCurrent()

var bundle = gw.transaction.Transaction.getCurrent()

Carmen
  • 1
  • 2