Skip to content

Pass selected field to Cloud Function script #2473

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

Closed
3 tasks done
mtrezza opened this issue Jun 23, 2023 · 8 comments · Fixed by #2483
Closed
3 tasks done

Pass selected field to Cloud Function script #2473

mtrezza opened this issue Jun 23, 2023 · 8 comments · Fixed by #2483
Labels
bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version type:feature New feature or improvement of existing feature

Comments

@mtrezza
Copy link
Member

mtrezza commented Jun 23, 2023

New Feature / Enhancement Checklist

Current Limitation

Currently, it cannot be determined which field was been selected when a script has been invoked.

Feature / Enhancement Description

Pass the selected field as a separate parameter to the Cloud Function payload.

For example the dashboard user should be able to invoke a script on a user in a specific field of the selected object:

  • Transaction class: buying user, selling user

Knowing only the "transaction" object is not enough to know on which user the Cloud Function should be executed.

Example Use Case

Parse.Cloud.define('deleteUser', async (req) => {
  const selectedTransaction = req.params.object;
  selectedTransaction.set('invalid', true);
  await selectedTransaction.set.save(null, { useMasterKey: true });

  const selectedUser = req.params.selectedField;
  if (selectedUser instanceof Parse.User) {
    selectedUser.set('deleted', true);
    await selectedUser.save(null, { useMasterKey: true });
  }
});

Alternatives / Workarounds

None.

@parse-github-assistant
Copy link

parse-github-assistant bot commented Jun 23, 2023

Thanks for opening this issue!

  • 🎉 We are excited about your ideas for improvement!

@mtrezza mtrezza added type:feature New feature or improvement of existing feature bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) labels Jun 23, 2023
@mtrezza mtrezza changed the title Pass selected field to Cloud Function script Pass selected field to script Jun 23, 2023
@mtrezza mtrezza changed the title Pass selected field to script Pass selected field to CloudFunction script Jun 23, 2023
@mtrezza mtrezza changed the title Pass selected field to CloudFunction script Pass selected field to Cloud Function script Jun 23, 2023
@mtrezza
Copy link
Member Author

mtrezza commented Jun 23, 2023

@dblythy What do you think?

@dblythy
Copy link
Member

dblythy commented Jun 28, 2023

Sounds good

@mtrezza
Copy link
Member Author

mtrezza commented Jun 28, 2023

To avoid any confusion for future readers, in your PR you're passing the name of the selected field, instead of the value of the selected field as suggested in the example use case. I think that makes more sense, because if there are 2 fields of the same type with the same value it wouldn't be possible to know which field was selected.

@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.2.0-alpha.23

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Jun 28, 2023
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.3.0-beta.1

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Sep 15, 2023
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.3.0-alpha.1

@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.3.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version type:feature New feature or improvement of existing feature
Projects
None yet
3 participants