Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing inputs for rules using ticket validation criteria #18578

Open
wants to merge 2 commits into
base: 10.0/bugfixes
Choose a base branch
from

Conversation

RomainLvr
Copy link
Contributor

Checklist before requesting a review

Please delete options that are not relevant.

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.
  • This change requires a documentation update.

Description

  • It fixes !35677
  • Here is a brief description of what this PR does

We create business rules for tickets, if we create a rule using only one criterion which is 'validation' it works, otherwise if we add another criterion in addition to 'validation' the rule never passes.

The problem comes from the fact that when the rule engine is run, the main item is CommonITILValidation, so the inputs to be processed come from this object, which does not contain the ticket fields. So you have to go and find the missing fields you need

Screenshots (if appropriate):

Work :
image

Dont work :
image

@RomainLvr RomainLvr self-assigned this Dec 19, 2024
src/Rule.php Fixed Show fixed Hide fixed
Comment on lines 453 to 457
'id' => $this->fields[static::$items_id],
'global_validation' => self::computeValidationStatus($item),
'_from_itilvalidation' => true,
'itemtype' => static::$itemtype
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'id' => $this->fields[static::$items_id],
'global_validation' => self::computeValidationStatus($item),
'_from_itilvalidation' => true,
'itemtype' => static::$itemtype
];
'id' => $this->fields[static::$items_id],
'global_validation' => self::computeValidationStatus($item),
'_from_itilvalidation' => true,
] + $item->fields;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we shouldn't simply pass the fields (from related item) in $input

@cedric-anne what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$item is a Ticket or a Change. If we update it with all its fields, isn't there a risk of triggering other rules?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's why I want cedric's opinion, because it may give rise to a PR on main (and therefore feature request).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants