Overlapping Business rule and Client scripts

jeremy_gardner
Tera Expert

Hello,

We have a asset record that contains, among other things, an "assigned to user" field which is a reference to the user table. When editing that user through the form view, a client script gets called that creates and queries a GlideRecord for that user's location and service line (our own custom fields added to user record). It then adds those values to similar fields on the asset record.

I'd also like people to be able to edit the records from the list view. When editing the "assigned to user" field, I was going to create a business rule that gets the user record, creates/queries a GlideRecord, then populates the corresponding location and service line fields on the current asset record.

Each of these parts works fine, however when editing through the form view both the client script AND the business rule get called.

Is there a way to tell the business rule to only fire if the client script did not? Or at least have some logic in the business rule that determines if the update came from the form or list? Something?

The wiki says best practice for both form and list editing is to use client scripts AND business rules, but the business rule wil run on both. What am I missing?

Thanks!
Jeremy

8 REPLIES 8


Hrm, I think I might be saying close to that, but not sure if that covers all scenarios. Let's say we have an employee (Bob) who normally works in St. Louis, but is working at a client in Denver. While Bob is in Denver, he gets a laptop (previously Joe's) to use at the client. So...

previous.assigned_to = Joe;
previous.billing_field = 303; // Denver

current.assigned_to = Bob;
current.billing_field = 314; // St. Louis

When editing through the form, the tech will assign the laptop to Bob, which will query Bob's record and add billing_field=314 to the asset. However, the tech changes that back to 303 so that it gets billed to the Denver office, and then saves the record. The billing field would essentially stay 303 for previous and current, right? At which point, the business rule would see that nothing changed and then update the record to say 314 (overwriting what the tech assigned). Am I describing the changes() behavior correctly?

I also thought about having the client script update a hidden field that the business rule could check.

I also have 3 billing related fields to track, not just 1, but even 1 works for this example. I think the logic around "if client script xyz ran, then skip" is simpler than checking a bunch of different fields, but then perhaps I could just push back for simpler logic at the expense of more functionality. One theme of #know11 after all. I'm open to rethinking logic, like you so cleanly provided John, but if there's a way the geek in me would still like to figure it out.

Signed,
Wanting cake and to eat it too...


I'm out of ideas. I would go with the resetting a field when the client script runs and checking in the rule. At least it's easy logic to follow down the road when someone is trying to troubleshoot it.


I appreciate all the feedback. I'm still learning, I don't know what I don't know, so it helps knowing that there's not something obvious I'm overlooking.

Thanks (to both of you).
Jeremy


s2ctnr
Kilo Explorer

Error in scheduled SNOW report

What the user gets in an automated scheduled report , is different from what he gets when he runs manually.But if the "Other threshold"field is filled with values 20 or 15 the automated scheduled report , is same as what he gets when he runs manually.

Can anyone please let me know why the same is not working for the other values filled in the "Other threshold" field.