You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @JagadishaBSfactResults are generated by the engine when it runs. It is only accessible via the on('success') event you already referenced.
I'll note that from the example you gave above, it looks to me like you're trying to pre-define factResults in the rule conditions, and have the values carry through as the engine runs (Let me know if I'm mis-interpreting). Rule conditions aren't meant as a means to store state - that's why they have a fairly rigid data structure. If you need to associate additional data with each rule, look to the events, where you can provide params. Finally, when needing to associate more complex data structures with a rule, don't be afraid to structure the data outside the engine - sometimes simply hashing the data by the event type in a variable, and then pulling out the data you need in the on('success') handler is a good way to go.
If you are still having problems or I'm misunderstanding your problem, it may helps to post a script/repo I can run that demonstrates your problem.
Hi
we have the number of a rule set for single questions like below
`conditions:
{
any: [{
all: [{
fact: 'gameDuration',
operator: 'equal',
value: '1',
factResult: [
{
"action": "do-something for gameDuration show ",
// i can add my custom params
}]
},
{
fact: 'personalFoulCount',
operator: 'equal',
value: '2',
factResult: [
{
"action": "do-something for personalFoulCount show",
}]
}],
},
{
all: [{
fact: 'gameDuration',
operator: 'Equal',
value: '2',
factResult: [
{
"action": "do-something for gameDuration hide",
}]
},
{
fact: 'personalFoulCount',
operator: 'equal',
value: '4',
factResult: [
{
"action": "do-something for personalFoulCount hide",
}]
}]
},
{
all: [{
fact: 'gameDuration',
operator: 'Equal',
value: '8',
factResult: [
{
"action": "do-something for gameDuration hide show",
}]
},
{
fact: 'personalFoulCount',
operator: 'equal',
value: '6',
factResult: [
{
"action": "do-something for gameDuration show hide",
}]
}]
},
]
},
event: {
type: 'json rule',
params: {
message: 'json rule example'
}
}`
and
let facts = { gameDuration: '2', personalFoulCount: '4' }
the rule will success for given facts
on success, i want the success "factResult" separately. is there any way we can access the succeed custom param.we tried with below example
https://github.com/CacheControl/json-rules-engine/blob/master/examples/09-rule-results.js
but could not able to succeed.
The text was updated successfully, but these errors were encountered: