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

Set result variable scope to element if output mapping exists #30

Merged
merged 3 commits into from
Jan 2, 2025

Conversation

abdul99ahad
Copy link
Contributor

@abdul99ahad abdul99ahad commented Dec 16, 2024

Related to: camunda-modeler #4737

Proposed Changes

Script Task

  • If output mapping exists, result variable scope should be local.
    Dec-16-2024 23-10-38

  • If output mapping doesn't exist, result variable scope is global.
    Dec-16-2024 23-09-56

You can test the implementation by running this command: npx @bpmn-io/sr bpmn-io/variable-resolver#variable-scoping -l bpmn-io/extract-process-variables#script-variable-scope

Checklist

To ensure you provided everything we need to look at your PR:

  • Brief textual description of the changes present
  • Visual demo attached
  • Steps to try out present, i.e. using the @bpmn-io/sr tool
  • Related issue linked via Closes {LINK_TO_ISSUE} or Related to {LINK_TO_ISSUE}

Comment on lines 39 to 51
// Checks if output variable exists, the scope gets redefined
if (processVariables.some(x => x.origin[0] === element && x.scope === containerElement)) {

// result variable will have local scope
containerElement = element;
}

Copy link
Member

Choose a reason for hiding this comment

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

[suggestion] Let's add an example to the functions JSDoc

@barmac
Copy link
Member

barmac commented Dec 17, 2024

Since this pull request applies to Business Rule Task implemented as a DMN decision, I'd suggest to add a respective test case, and document it in the pull request. When this is done, I think it's ready to merge. Great job :)

Copy link
Member

@barmac barmac left a comment

Choose a reason for hiding this comment

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

Approved with comment above :)

@abdul99ahad abdul99ahad force-pushed the script-variable-scope branch from 3322ea3 to cbad563 Compare December 23, 2024 14:35
@nikku
Copy link
Member

nikku commented Jan 2, 2025

Great work 👏

@nikku nikku merged commit d48df0a into main Jan 2, 2025
4 checks passed
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label Jan 2, 2025
@nikku nikku deleted the script-variable-scope branch January 2, 2025 06:56
@nikku
Copy link
Member

nikku commented Jan 2, 2025

Released as v1.0.1, followed up with some housekeeping.

@philippfromme philippfromme changed the title fix: script task result variable scope redefines if output mapping exists Set result variable scope to element if output mapping exists Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants