0 votes

I had a business rules that had a PowerShell script to update User properties in a SQL table. It was working fine.

I moved the PowerShell to a custom command so I could use it in multiple business rules. But now the PowerShell in the custom command does get the values for the User object.

Am I missing something?

by (730 points)
0

Hello,

Can you post the PowrerShell script that you use here or send it to our support e-mail (<support[at]adaxes.com>)?

0

Thank you I just emailed the script

1 Answer

0 votes
by (216k points)

Hello,

The thing is that in your script, you use the $Context.GetModifiedPropertyValue method to get the values entered by users. It works in Business Rules, because Business Rules are triggered by a certain operation (creating a user or updating a user), and the values are modified or set by that operation. However, when you call a Custom Command from your Business Rule, this is a completely different operation, and it doesn't modify any values. It only runs a Custom Command. That's the reason why the $Context.GetModifiedPropertyValue method fails.

0

OK, I understand. So, in my situation how can I solve my problem?

I need to run the update script only when some of the properties are modified. And I need to call this from multiple Business Rules.

Is there no way to do it other than by duplicating the script in the Business Rules?

0

Could you describe in a bit more detail what task you want to achieve with the Business Rules and when are the Business Rules triggered? As far as we understand, your Rules are triggered before the main operation (e.g. before updating a user). This is not a good idea at all because if an operation fails for some reason (for example, if the initiator doesn't have sufficient access rights), the values specified by the user will not be saved to the AD, but will be saved to the SQL database anyway.

Related questions

0 votes
1 answer

Hello, I'm trying to execute a custom command through a Powershell script, but I'm struggling to pass multiple values to an AD Object Picker parameter. ... , $NULL, $NULL, 0) $obj.ExecuteCustomCommand($command.CommandID, $commandArguments) Thanks in advance!

asked Nov 24, 2021 by KelseaIT (320 points)
0 votes
1 answer

Is it possible to have custom command that doesn't execute on a specific (or any) AD object? I realize Adaxes is for AD management, but I was wondering if it would be ... to execute against and AD object, I just need it to talk to the SQL server. Thanks

asked Nov 9, 2012 by bemho (520 points)
0 votes
1 answer

Can you run a powershell to get a Custom Command's ID?

asked Jun 10, 2020 by hgletifer (1.3k points)
0 votes
1 answer

We currently have a form for HR to deal with ex-employees that are hired once more, but it's not much more than automatic emails sent to IT. If I add some actions ... this trigger the business rule we have that targets "After updating a user" ? Thanks, Louis

asked Oct 18, 2022 by lw.fa (150 points)
0 votes
1 answer

Is there a way to get the name of the user who approved a request and supply that to a step inside of a custom command? For example, HR submits a status change for an employee. ... and pass it as a param in a custom command that is called in one of the steps?

asked May 12, 2021 by davfount90 (20 points)
3,588 questions
3,277 answers
8,303 comments
548,090 users