Home > Forum > Rules, JS, SQL > The use of multiple global business rules in one global business rule

The use of multiple global business rules in one global business rule
0

MVP

Hello,
I tried create sql script for created a global business rule with existing multiple global business rules .
I tried use of multiple global business rule ( with parameters) in one global business rule (with parameters).
Every global business rule used has parameters.
The business rule that appeals to the other business rules has parameters that are mapped in the appealed rules.
I get the error when I testing.
I explained the error and showed the code in the attached image.

Thank you,
Raluca

MVP
In reply to: Daniel Krüger (Cosmo Consult)

Hi Raluca,

in these kind of cases I always use the SQL Profiler to start a trace so that I can get the executed SQL statement with the resolved parameters.
The results of the parameters will be directly inserted in the text, they are not variables, so a ' character or -- may break your statement.

Best regards,
Daniel

Hi,
Thank you for answer.
I've tested every global business rule and it's okay.
I tested in my global business rule, the sql script with global business rules, but I send the harcoded parameters and it worked. I changed the value with the defined parameters and I get the error.
The problem is when I replace the harcoded value with defined parameters.
I attached a image with both situations: works and not works

Thank you,
Raluca

MVP
In reply to: Daniel Krüger (Cosmo Consult)

Hi Raluca,

in these kind of cases I always use the SQL Profiler to start a trace so that I can get the executed SQL statement with the resolved parameters.
The results of the parameters will be directly inserted in the text, they are not variables, so a ' character or -- may break your statement.

Best regards,
Daniel

Hi,
I used sql profiler and I remarked the problem.
The defined parameters from global business rule is recognized in the first global business rule from sql script ( from the concatenate multiple global business rules from sql script ), but isn't recognized in second business rule.
In the attached image I showed the problem
The script sql from sql profiler for first global business rule from the concatenate multiple global business rules from sql script is :
SELECT WFD_AttText4
FROM WFElements
WHERE WFD_ID = '43637'
For second global busines rule is:
SELECT
(CASE
WHEN WFD_STPID = 152 THEN 'în faliment, in bankruptcy, en faillite'
WHEN WFD_STPID = 170 THEN 'in reorganizare judiciara, in judicial reorganisation, en redressement'
ELSE 'în insolvenţă, in insolvency, en procedure collective'
END) as R
FROM WFElements
WHERE WFD_ID = '{BRP:177}'In the second and other business rules besides the first business rule, the mapped parameters are not known.

MVP
In reply to: Raluca-Mirabela Lupu

Hi,
I used sql profiler and I remarked the problem.
The defined parameters from global business rule is recognized in the first global business rule from sql script ( from the concatenate multiple global business rules from sql script ), but isn't recognized in second business rule.
In the attached image I showed the problem
The script sql from sql profiler for first global business rule from the concatenate multiple global business rules from sql script is :
SELECT WFD_AttText4
FROM WFElements
WHERE WFD_ID = '43637'
For second global busines rule is:
SELECT
(CASE
WHEN WFD_STPID = 152 THEN 'în faliment, in bankruptcy, en faillite'
WHEN WFD_STPID = 170 THEN 'in reorganizare judiciara, in judicial reorganisation, en redressement'
ELSE 'în insolvenţă, in insolvency, en procedure collective'
END) as R
FROM WFElements
WHERE WFD_ID = '{BRP:177}'In the second and other business rules besides the first business rule, the mapped parameters are not known.

Hi Raluca,

as you noticed, the question is, why was the parameter not replaced. I had this case once, but this was when I used the PowerShell action. The {} of the script block caused the problem, but I doubt you have similar problem here.

Unfortunately I wasn't able to reproduce it. I used one business rule, which referenced two others, and the second one used the first one. Every rule, except the first one has a parameter and these are all replaced correctly. The screenshot looks a bit confusing because of the nested rules and their parameters. You will notice that there's no need to declare a variable, a simple select will be sufficient.

On a side note, I cloned one of the rules and the parameter wasn't correctly replaced. Maybe it's worth to check you rules whether the string '{BRP:177}' is really a text instead of a parameter.

I'm using BPS 2022.1.1.41.

Best regards,
Daniel