Search code examples
gosuguidewire

Cannot modify a bean of type User that is in a readonly bundle


I've added a new field to user.etx called LastLoggedIn_Ext. But getting an error when trying to write to it:

Cannot modify a bean of type User that is in a readonly bundle

My code:

user.Ext_LastLoggedIn = Date.Now

Is there a way to bypass read only bundle so that I can save the time the user last logged into PolicyCenter in the user.etx table?


Solution

  • You have to add it to writable bundle, for example

    gw.transaction.Transaction.runWithNewBundle(\bundle -> {
          var writableUser = bundle.add(user)
          writableUser.Ext_LastLoggedIn = Date.Now
        })