Business Service Property Methods

The ServicePropertyAccess class provides two utility methods for accessing property values. These methods are:

  • Get property value and return null/blank if no value exists in the database, illustrated in this code sample:

    getSvcPropertyValue(IContext context, java.lang.String key) 
      
    Example:  String processingVersion = ServicePropertyAccess.
    getSvcPropertyValue(context,SVC_PROPERTY_AB_MBF_PROC_VERSION );
    
  • Get service property value, but if the value is null, use the provided default value, illustrated in this code sample:

    String getSvcPropertyValue(IContext context, java.lang.String key, 
    java.lang.String defaultVal)
    Example:  String programID = ServicePropertyAccess.getSvcPropertyValue
                         ((Context)context, SVC_PROPERTY_PROGRAM_ID,"BSSV");
    

Both of these methods throw a ServicePropertyException message when the property key is null or does not exist in the database. A business service must call these methods in a try/catch block and catch the ServicePropertyException. You can handle business service property errors by creating a new E1Message object that collects the business service property exception message as well as other errors retrieved from business function calls. The business service returns the E1Message object to its caller, and the exception and error messages can be included in the BusinessServiceException, which is thrown by the published business service. When you create the business service, you determine whether to continue processing if an exception is caught. If you allow processing to continue, a failure (an invalid value was passed because of the ServicePropertyException) could occur in the call to the business function. Including text for the exception offers more information as to why the error occurred.

You can use the code template E1SD – EnterpriseOne Add Call to Service Property with Default Value to generate code that calls the business service property method where a default value is passed. The template generates the code and highlights the fields that you need to change.

You can use this code sample as a model for handling business service properties:

   public static final String SVC_PROPERTY_AB_MBF_PROC_VERSION = 
"J010010_AB_MBF_PROC_VERSION";
   public static final String SVC_PROPTERY_PROGRAM_ID = 
"SYS_PROGRAM_ID";
   ... 
               //Call access  Business Service Property to retrieve 
               //Program ID and processing Version
               //create string so it can be passed to bsfn call
               String programId = null;
               //Call to return Business Service Properties - if fails  
               //to retrieve value, use default and continue.
               try {
                   programId = 
                           BusinessServicePropertyAccess.
getSvcPropertyValue(context, SVC_PROPERTY_PROGRAM_ID, "BSSV");
               } catch (BusinessServicePropertyException se) {
                   context.getBSSVLogger().app(context,"@@@Attempt to 
retrieve Business Service Property failed", "Verify that key exists 
in database as entered.", SVC_PROPERTY_PROGRAM_ID, se);
                   //Create new E1 Message using DD item for business 
                   //service property exception.
                   E1Message scMessage = new E1Message(context, 
"001FIS", SVC_PROPERTY_PROGRAM_ID);
                   //Add messages to final message list to be returned.
                   messages.addMessage(scMessage);
               }