Question

How to get Localizable String from Object Event

Hi Bpm'online Community,

I'm new to bpm'online and I'm trying to validate an object on the Saving - Validate event. I added the event and I'm able to write the logic that throws an exception if the validation fails. Now, I want to get the exception message from the LocalizableStrings structure on the event.

I added a new localizable string schema but I cannot how to get it from the script.

This is the code of the script:

var cfrStageId = Entity.GetTypedColumnValue<Guid>("UsrCfrStageId");
var errorMessage = string.Empty;
if (!cfrStageId.ToString().Equals(UsrCfrConstants.Initiation, StringComparison.OrdinalIgnoreCase)) {
 var numberOfBeneficiaries = Entity.GetTypedColumnValue<int>("UsrNumberOfBeneficiaries");
 if (numberOfBeneficiaries < 1) {
  //errorMessage = new LocalizableString(Storage, Schema.GetResourceManagerName(),
          //                          "LocalizableStrings.NumberOfBeneficiariesNotPositive.Value").ToString();
        errorMessage = "The number of beneficiaries must be > 0";
  throw new Exception(errorMessage);
 }
}
return true;

The commented out code is what is not working. I also tried "UsrCfrEventsProcess" as the resource manager name but it did not work either.

 

I'd appreciated any help you can provide.

 

Thanks,

Jose

Like

1 comments

I would say that you need to build the localizable string in the following way:

string title = UserConnection.GetLocalizableString("YourSchemaName", "LocalizableStringName");

or if it's the same schema.

string title = UserConnection.GetLocalizableString(Schema.GetResourceManagerName(), "LocalizableStringName");

However, you need to test this. 

Please deploy the application locally and debug it. This way you'll see how to resolve the issue. 

Log in or register to comment