0

I am trying to add a user into a global group with global role in Polarion using workflow script by providing an input. Can you please help me how to call the below packages into workflow script?

  • com.polarion.alm.shared.api.model.usergroup
  • com.polarion.alm.shared.api.transaction

also, how to write the below code in workflow script?

TransactionalExecutor.executeInWriteTransaction(transaction -> {
       UpdatableUserGroup updatableUG =       transaction.userGroups().getBy().id("groupId").getUpdatable(transaction);
       UpdatableUsersField updatableUsersField = updatableUG.fields()._users();
       updatableUsersField.addUser("dummy_user");
       updatableUsersField.addUser("dummy_user2");
       updatableUG.save();
       return null;
   });
James Z
  • 12,209
  • 10
  • 24
  • 44
Nayudu
  • 1

2 Answers2

0

First of all, the workflow script functions are written in Javascript. The documentation of both API's provided by Polarion (rendering API and open API) might help you on that.

Also, an interesting site I have found is following: https://polarion.code.blog/category/technological/javascript/

There are quite interesting blog posts to see.

Second, I am not 100% sure, but I think that workflow functions might not allow WriteTransactions, especially on such high level (global administration). Better alternative might be the extension "Active Questionaire". That is based on SurveyIO, you can create your own "survey form" and eventually execute a JavaScript based on the inserted data.

0

In a Workflow action this is (in general) not possible.

  1. You cannot nest transactions, and the workflow function is already in a Transactional state
  2. The script runs under the user who triggered the status transition, so this user need to have admin permissions to globally modify configurations.
  3. The Polarion API does not support administration actions
  4. your example uses some rendering API( I think?) this is totally not usable for the Workflow action where you need the classic Polarion API
Peter Parker
  • 29,093
  • 5
  • 52
  • 80