Clear a custom lookup field  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Clear a custom lookup field

Postby SBarnes » Tue Mar 12, 2019 10:12 am

I know how to set up a custom field as a look up field by using read data and button clicked, but is there a way to give the user the ability to clear the value back to nothing?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1620
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Clear a custom lookup field

Postby Scott.Pearce » Tue Mar 12, 2019 10:23 am

Have a look at the Coordinator lookup on the top right of the Service Manager screen. By right-clicking, some options are given, including one to "Clear". Below is the code used in form setup to achieve this:

Code: Select all
Private Sub SetupControls()
        Dim NewToolStripMenuItem As ToolStripMenuItem

        'Coordinator context menu
        Dim myCoordinatorContextMenuStrip As ContextMenuStrip

        myCoordinatorContextMenuStrip = New ContextMenuStrip

        NewToolStripMenuItem = New ToolStripMenuItem("Clear", Nothing, AddressOf ClearCoordinator, "Clear")
        myCoordinatorContextMenuStrip.Items.Add(NewToolStripMenuItem)

        Dim newToolStripMenuItemSeparator As New ToolStripSeparator
        myCoordinatorContextMenuStrip.Items.Add(newToolStripMenuItemSeparator)

        NewToolStripMenuItem = New ToolStripMenuItem("Set as default", Nothing, AddressOf SetCoordinatorAsDefault, "Set as default")
        myCoordinatorContextMenuStrip.Items.Add(NewToolStripMenuItem)

        NewToolStripMenuItem = New ToolStripMenuItem("Clear default", Nothing, AddressOf ClearDefaultCoordinator, "Clear default")
        myCoordinatorContextMenuStrip.Items.Add(NewToolStripMenuItem)

        CoordinatorLookup.ContextMenuStrip = myCoordinatorContextMenuStrip
End Sub

Private Sub ClearCoordinator(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Job.Coordinator.Clear() 'Coordinator is a staff entity
End Sub

Private Sub SetCoordinatorAsDefault(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Job.SetCoordinatorAsDefault()
End Sub

Private Sub ClearDefaultCoordinator(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Job.ClearDefaultCoordinator()
End Sub
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 743
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Clear a custom lookup field

Postby SBarnes » Tue Mar 12, 2019 10:32 am

Sorry Scott,

I am a little bit lost I am referring to say a look up custom field on inventory?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1620
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Clear a custom lookup field

Postby Scott.Pearce » Tue Mar 12, 2019 10:45 am

My bad, I didn't read the post properly. However, the approach would be the same. Context menu on the grid with an option to "Clear" the cell clicked on (which would translate back to clearing the underlying business logic object/property). I'll see if I can slap an example together for you....
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 743
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Clear a custom lookup field  Topic is solved

Postby Scott.Pearce » Tue Mar 12, 2019 12:40 pm

Sample plugin for 7.2.0.0 attached. Admittedly it's a bit of a production.
Attachments
Plugin Inventory Look Up Custom Field Clear Example.xml
(35.73 KiB) Downloaded 88 times
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 743
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Clear a custom lookup field

Postby SBarnes » Tue Mar 12, 2019 12:41 pm

Thanks.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1620
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 11 guests