Lock SO 'Expected Delivery' Date  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Lock SO 'Expected Delivery' Date

Postby 2can2 » Thu Dec 17, 2015 2:39 pm

Hi, I am setting ExpectedDate = SO.InitiatedDate in Private Sub SOSaveEnd(sender As Object, e As EventArgs) as below

Private Sub SOSaveEnd(sender As Object, e As EventArgs)
SO.InitiatedDate = SO.ExpectedDeliveryDate
End Sub

However on Save the SaveIcon is always highlighted? If I close the SO and say Save changes it updates correctly!

2nd Part - I also want to LOCK 'Expected Delivery'. I have code to lock Custom grid but can't get this filed to work.

V129. Thanks.
2can2
Frequent Contributor
Frequent Contributor
 
Posts: 171
Joined: Tue Feb 26, 2008 10:24 am
Topics Solved: 25

Re: Lock SO 'Expected Delivery' Date  Topic is solved

Postby Mike.Sheen » Thu Dec 17, 2015 7:50 pm

2can2 wrote:Hi, I am setting ExpectedDate = SO.InitiatedDate in Private Sub SOSaveEnd(sender As Object, e As EventArgs) as below

Private Sub SOSaveEnd(sender As Object, e As EventArgs)
SO.InitiatedDate = SO.ExpectedDeliveryDate
End Sub

However on Save the SaveIcon is always highlighted? If I close the SO and say Save changes it updates correctly!


That code looks as though the intent is actually the opposite of what you are saying you want... plus it should be throwing an exception as your SOSaveEnd method has no knowledge of an "SO" variable, or object - you want to cast the sender as a type of SalesOrder - I can only assume we're talking sales order as you reference an InitiatedDate property and I think that's the only type we have with such a property.

SaveEnd occurs after the sales order is saved and all changes are committed to the database. Setting a property after that - as you are - will cause the changeflag to be set, and the UI to indicate that.

You really want to set any properties in the SaveStart event - then it will behave as you want.

2can2 wrote:2nd Part - I also want to LOCK 'Expected Delivery'. I have code to lock Custom grid but can't get this filed to work.

V129. Thanks.


The date control on the sales order form is called DTExpectedDeliveryDate - you will need to instruct that to be read-only at appropriate places - e.g.: salesOrderForm.DTExpectedDeliveryDate.Enabled = False. The appropriate places would whereever the form redisplays - in this case ReadEnd, CreateEnd and PropertyChanged.

Attached is a sample plugin which I believe does what you want.

NOTE:You can also disable fields for entry using the permissions system - you may want to consider that for locking the Expected Delivery date field, rather than having plugin code do it. If you ever start having conditions around which users can edit the field, then you should definitely use permissions.
Attachments
Plugin Sales Orders - Set Expected Delivery Date and Make ReadOnly.xml
Sample plugin
(32.53 KiB) Downloaded 365 times
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Lock SO 'Expected Delivery' Date

Postby 2can2 » Fri Dec 18, 2015 6:45 pm

Thanks Mike - extremely helpful!
2can2
Frequent Contributor
Frequent Contributor
 
Posts: 171
Joined: Tue Feb 26, 2008 10:24 am
Topics Solved: 25


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 1 guest