This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Merging data from relationship DOM and server in OnBeforeSave?

jenC - Friday, February 26, 2010 12:29 PM:

I need to do some server side checking in an OnBeforeSave event for an itemtype with a relationship that has a quantity property.

I need to make sure that the sum of the quantity property for all related items doesn't exceed a total on the parent Item.

So, if either the total on the parent item or the quantity on any of the related item changes, I need to run my check.

 

The problem is, the Me.dom in the OnBeforeSave event only contains the related items that have been altered.

What is the best way to get all of the related items (regardless of whether they've been updated or not) in the server event so that I can check the sum?

When I try:

Dim x as Item = Me.newItem("Related Item Type", "get")
x.setProperty("source_id", Me.getID())
x = x.apply()

I only get the old server side data.  How do I merge that with the newly edited yet unsaved client data that is in the Me.dom?

Thanks!

 

 



jenC - Tuesday, March 2, 2010 4:58 PM:

Anybody?  I'm looking for a simple way of adding up a total value of counts of both the changed and unchanged data in a relationship grid in the OnBeforeSave event of the parent item....

Am I going to have to do this the ugly way and merge the data myself in an OnBeforeSave event?



Brian - Tuesday, March 2, 2010 11:23 PM:

Hi Jen,

I think that I came across a similar requirement when trying to make a Filtered Item Browser (http://www.aras.comhttp://www.aras.com/Community/wikis/kb/filtered-item-browser.aspx).

The bit of interest for you is probably the

var itm = inArgs.itemContext;

The itemContext is essentially the AML document for the entire User Interface and so contains all of the retrieved information and any unsaved changes made by the user.

Once you have the itemContext you can retrieve the parts of the relationship that you are interested in and do your counts from there.

Hope this helps.

Brian.



jenC - Wednesday, March 3, 2010 11:39 AM:

Hi Brian,

Thanks for the reply but inArgs is for the client side event. I already have client side checks but I need to do server side as well since someone always manages to find a way around the client side checks.... 

I need to do this in the OnBeforeSave for the parent item on the server side.