cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Email Notification via CLI

amund
12-Amethyst

Email Notification via CLI

Hello All,

To make it easier to create notification rules, I would like to provide our users a batch file they just need to run.

Creating and running the file is no problem and works fine, but "Set Email Notifications" should look like this:

amund_1-1611058206503.png

Unfortunately, I have not yet been able to find out how to set up "New Value" via the CLI.

 

When I output the above settings in the CLI (via "Im viewuser") I get the following NotificationRule:

((((field["Assigned User"] <> "me") and (field'["Assigned User"] = "me") and (field["Modified By"] != "admin")) and ((field["Type"] = "Request for Change") or (field["Type"] = "Change Order") or (field["Type"] = "Defect"))))


The "New Value" of "Assigned User [New Value]" is completely missing here. If I would use this in the batch file, I would not get the desired notifications.

 

How can I set the "New Value" in the CLI? What do I have to enter?

 

Many thanks in advance!

ACCEPTED SOLUTION

Accepted Solutions
ascott
17-Peridot
(To:amund)

The new value is represented by a single quote after the field keyword.


For example:

im edituser --notificationRule="(field'[State] = ALM_Active)" ascott

 

Will show as State [New Value] = ALM_Active

 

I hope this helps!

-Andrew

View solution in original post

4 REPLIES 4
ascott
17-Peridot
(To:amund)

The new value is represented by a single quote after the field keyword.


For example:

im edituser --notificationRule="(field'[State] = ALM_Active)" ascott

 

Will show as State [New Value] = ALM_Active

 

I hope this helps!

-Andrew

amund
12-Amethyst
(To:ascott)

Hello ascott,

Thank you for your response!

 

I was actually thinking the same thing.

 

As you can see in the first post, I got a single quote when outputting the notification rule from GUI.

Unfortunately, it doesn't work the other way around though. When I copy the rule one to one and return it via CLI or batch-file no "New Value" is displayed. The single quote is simply skipped.

 

It is the same with <> in the desired notification rule.
In the GUI I can select <> and also output it via CLI (output is: field["Assigned User"] <> "me").
If I copy this one-to-one and want to return it via CLI, I get the following message:
">" cannot be processed syntactically at this point.
It can only be processed if I use field["Assigned User"]"<>me"

 

Do you have any idea why the single quote is skipped here, or why <> is not accepted outside the quotes?

ascott
17-Peridot
(To:amund)

It is tempting to follow the syntax of viewuser in your edituser command; however, all those double quotes cause problems. Here is my suggestion:

  • Use double quotes to wrap your --notificationRule="
  • do not use any more double quotes within that  string.

Here is a working example that successfully runs from a batch file:

im edituser  --notificationRule="((field'[State] = ALM_Active) and (field'[Type]<> ALM_Requirement Document))" ascott

 

Notice how no quotes (of any kind) are necessary  around the field names - even when they contain a space. 

amund
12-Amethyst
(To:ascott)

Thank you very much!

If only the double quotes are used at the beginning and end, it works fine. Also the [New Value] is now inserted correctly.

Great!

Announcements


Top Tags