ForumFirstTimer

Cadet 1st Class
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-07-29
22:13
4739 views
I have a field A, which I am trying to detect a change in on the client and then pass a flag to the server in field Z.
I am using AddChangeCallback to set field Z when A changes.
On the server I am able to query field Z to know that A has changed during the transition.
However, I have a field Q which is a required field.
If I change field A and leave field Q blank then the server side validation fails and this causes the page to reload.
When the page is reloaded field A still contains the new value, but I no longer know that this has changed.
Is there a better way to reliably detect changes in the client? At present I am checking whether an error is displayed on page load and if so then I have to assume everything has changed which is not ideal for me. I have submitted another post recently about this... I am trying to call a web service method on the server, but this is an expensive operation and I would only like to do this when a field is actually changed.
Any help or thoughts about this would be much appreciated... thanks!!
I am using AddChangeCallback to set field Z when A changes.
On the server I am able to query field Z to know that A has changed during the transition.
However, I have a field Q which is a required field.
If I change field A and leave field Q blank then the server side validation fails and this causes the page to reload.
When the page is reloaded field A still contains the new value, but I no longer know that this has changed.
Is there a better way to reliably detect changes in the client? At present I am checking whether an error is displayed on page load and if so then I have to assume everything has changed which is not ideal for me. I have submitted another post recently about this... I am trying to call a web service method on the server, but this is an expensive operation and I would only like to do this when a field is actually changed.
Any help or thoughts about this would be much appreciated... thanks!!
1 Solution
Accepted Solutions
lmattie

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-07-30
04:56
I'm not sure why field Z wouldn't retain its new value, unless you are clearing it on form load.
Can you fire the orchestration from the notification, instead of the transition? Then you pretty much define exactly the rule you want and can include Field A Changes.
Can you fire the orchestration from the notification, instead of the transition? Then you pretty much define exactly the rule you want and can include Field A Changes.
14 Replies
lmattie

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-07-30
04:56
I'm not sure why field Z wouldn't retain its new value, unless you are clearing it on form load.
Can you fire the orchestration from the notification, instead of the transition? Then you pretty much define exactly the rule you want and can include Field A Changes.
Can you fire the orchestration from the notification, instead of the transition? Then you pretty much define exactly the rule you want and can include Field A Changes.
PM Thompson

Fleet Admiral
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-08-03
02:12
How about doing the validation of field Q with JavaScript or Form Actions. That saves the round-trip to the server. See the docs on "AddSubmitCallback".
jmalin

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-08-05
03:19
You can use an AppScript to compare the DB Value with the current value in the post-transition context. Here's a utility function to do this:
function checkFieldChanged(fieldName)
dim fldObj, currValue, dbValue
set fldObj = shell.item.Fields().FindField(fieldName)
fldObj.getValue(currValue)
fldObj.getDBValue(dbValue)
if currValue = DBValue then
checkFieldChanged = false
elseif currValue = "" and dbValue = -2 then ' Workaround for null Date issue
checkFieldChanged = false
else
checkFieldChanged = true
end if
end function
ForumFirstTimer

Cadet 1st Class
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-08-11
23:03
Following on from Jeff's suggestion, the problem I would have is that if I have an AppScript and an Orchestration that both need to fire post-transition then I can't get the AppScript to fire before the Orchestration.
I need to fire the AppScript first to store a value in a field to indicate that another field has changed and then this can be passed to the Orchestration, but I cannot seem to be able to configure the order in which they fire.
I need to fire the AppScript first to store a value in a field to indicate that another field has changed and then this can be passed to the Orchestration, but I cannot seem to be able to configure the order in which they fire.
ForumFirstTimer

Cadet 1st Class
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-09-07
20:58
Thanks everyone for your help with this! After mulling this over some more I think what would have made this a lot easier is if I didn't have so many transitions where the same field could be updated. I think the workflow and forms are just badly designed and you can pretty much change everything on every transition. On most of the transitions I think I should be using less generic forms where only certain fields can be changed. If the field I was interested in could only be changed on 1, or perhaps a few, transitions then this would have made both solutions above really simple. Thanks again!
lmattie

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-09-21
22:57
You may not need new forms, just field overrides. I usually set most of my fields to Read Only by default, and then override them on the transitions where it makes sense for users to be updating them. Sometimes I create special transition forms, but if the correct fields are Read Only, you can use the same transition form for multiple transitions.
ForumFirstTimer

Cadet 1st Class
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-08-11
22:32
I am clearing the field on form load, which is the cause of the problem. I am wondering whether to clear the field on the server instead... possibly in a pre-transition step or set the field to a default value for each transition, and/or possibly reset the field on the post-transition step once I have processed my on change handling on the server.
ForumFirstTimer

Cadet 1st Class
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-08-11
22:35
I am not sure whether you can fire orchestrations from notifications, it has not been something I have actually looked into... do you know if this is possible? However, what I am trying to achieve is complex server side validation using a web service method, so the idea was to use a synchronous orchestration on my transition, so that I can then throw an error and prevent the transition from occurring. I am not sure whether you would be able to achieve the same thing and prevent a transition using notifications... I would expect not, but again this is not something I have looked into.
lmattie

Absent Member.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-08-11
22:44
On the transitions that are using the form, you can override the field and choose to Clear the field. This will occur before the form comes into play and the field would not be cleared again because of a missing required field.
You can fire an orchestration from a notification, but it would be an asynchronous orchestration.
You can fire an orchestration from a notification, but it would be an asynchronous orchestration.
ForumFirstTimer

Cadet 1st Class
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-08-11
22:44
Yes, that would indeed solve the issue in this particular case and would certainly be an improvement on what I have currently done. The problem is that I have other server side validation and for this to work well I would have to do all my validation on the client, which cannot always be easily done, especially if there is more complex server side validation. I could also not guarantee that someone would not add additional server side validation in future, but I guess I could fall back to my "there is an error so my field might have changed" handling... it's certainly a possible option!
ForumFirstTimer

Cadet 1st Class
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-08-11
22:57
I really like the idea of detecting the change on the server... it seems like the sensible and most reliable place to do this and the provided utility function is really handy. However, the problem I have is how can I get the result of this app script to be used in an Orchestration. My thinking was have an app script that stores the result in a separate field and this can then be passed to the orchestration... it sounded very promising! The problem with this is that the Orchestration seems to be invoked before the app script is run with no way of changing the order. I'll explain this in a separate reply so I can include a picture to make this clearer.