1. Amit Sharma
  2. PowerBuilder
  3. Wednesday, 1 September 2021 20:26 PM UTC

HI,

I am trying to create business rule engine in my application where rules are given an ID and stored in DB table. Rule's coding done using nvo function. I wanted to see if I can store that function name in a DB table and call it dynamically depending which rule is configured. Is this possible in PowerBuilder?

Table structure more like

Tbale - RuleId, RuleName, PBFunction

Values - 1, ClaimNoReq, nvo_ruleengine.ClaimNoRequired()

Call the above function for rule id 1.

Thanks.

John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 1 September 2021 21:40 PM UTC
  2. PowerBuilder
  3. # 1

Hi, Amit -

Chris is correct.

If you choose to try the technique he has described and you need the ability to pass argument value(s) through the event to the NVO function, please be aware the the TriggerEvent PowerScript function is quite limited as to the argument values you can pass to the event. I highly recommend you carefully read the PB Help section "TriggerEvent (PowerScript function)" as well as familiarize yourself with the WordParm and LongParm properties of the Message object.

If you do not need to pass argument values, an alternative would be to include a "directing" function in the NVO that takes the name of the function to be called as a string argument and uses a Choose Case statement to invoke the requested function. It's not truly dynamic in the way you have described, but it might be adequate for your needs. Something to consider...

Good luck!

Comment
  1. John Fauss
  2. Wednesday, 1 September 2021 22:02 PM UTC
Doh! Excellent point, Chris - Thanks for calling me out on it!
  1. Helpful
  1. Chris Pollach @Appeon
  2. Wednesday, 1 September 2021 22:05 PM UTC
John ... May I suggest "lots more coffee" ... always works for me - LOL! ;-)
  1. Helpful
  1. John Fauss
  2. Thursday, 2 September 2021 01:31 AM UTC
I don't drink coffee... maybe that's my problem! ;-)
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 1 September 2021 21:17 PM UTC
  2. PowerBuilder
  3. # 2

Hi Amit;

  No, Functions cannot be dynamically controlled under PowerScript but Events can. Thus, if you create an Object Class Event(s) that in turn calls the real object functions as an "interface" - then that would work. For example ....

 

HTH

Regards ... Chris

Comment
  1. Amit Sharma
  2. Wednesday, 1 September 2021 21:32 PM UTC
Perfect Chris. This is exactly what I was looking for. Thank You.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Wednesday, 1 September 2021 21:57 PM UTC
Awesome... Glad to have helped! :-)
  1. Helpful
  1. Roland Smith
  2. Thursday, 2 September 2021 12:56 PM UTC
Arguments could be placed in a generically named string instance variable which would then be parsed out by the event prior to calling the function.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.