Job Entry - Find Job Material Part Tool

Akin to my previous posts:

… and…

I figured I’d complete the cycle and create a Find Job Material Part “tool”.

Find Job Material by PartNum - tool

Choose the instance you want (as the same material could appear in multiple places on large jobs):

Tree Refreshes to desired Material record:

Nuts & Bolts details below should you like to recreate for yourselves…

~*~

As before, we’ll start with pretty simple BAQ:

Querying the JobMtl table and linking JobAsmbl for a little detail:

(Feel free to expand on this BAQ as much as you want/need based on the details you want to display in the resulting grid).

Set to Shared, Save. Done.

~*~

App Studio - BAQ DataView & Get Event

Use the Dataview Wizard to create your new BAQ Dataview pinned to the query above. The Wizard will create the “Get” event for you.

In the “Get” event, go into the kinetic-baq action > Properties > BAQ Execute Options

Add the below to your BAQ’s “Where” clause:
JobMtl_JobNum = '{KeyFields.JobNum}' AND JobMtl_PartNum = '{TransView.FindJobMtl}'

Save. Done.

~*~

App Studio - New Page - Find Job Material

Add a new slider page.

Form:

Top Panel Card:
Textbox bound to TransView.FindJobMtl
Search Button

Second Panel Card:
I created a parent panel card so I could pull the “OK” button closer to the action. So I ended up with a panel card grid IN a panel card.

Panel Card Grid > Grid Model > bind the grid to your BAQ dataview and set up your columns.
Add an “OK” button

Save. Done with form.

~*~

App Studio - New Tool

Back in the Application Map, click on a page (I generally just use Details) open Advanced > Tools > Click the (+) icon to create a new tool:

Save. Done. Preview to make sure your new tool is visible.

NOTE: Assuming you gave your tool a binding, you can set your tool to invisible via datarule if you’re not on the Job Assemblies tab page.

To do this, search for and copy the base hideFindAssemblyTool and add your tool’s binding to the Actions:

~*~

EVENTS:

Event #1 - Open Slider Panel

Create this one from scratch.

No Trigger.

Row-Update: (this serves as a reset in the case you use your tool multiple times)

Slider-Open: Set this to open your new form.

Save.

~*~

Event #2 - OnClick_toolFindJobMtl

search for the stock OnClick_toolFindAsm event, right-click and copy.

Rename
Change the trigger to onClick of your FindJobMtl tool
Change the event-next(2) to your new slider-open event (event #1 above)

Save.

Preview (if you wish), your tool should now open your slide-out panel.

~*~

Event #3 - FindJobMtl_Search

Back on your FindJobMtl page, we need to add an onClick event to the Search button to call our BAQ.

event-next > set to call your BAQ “get” event
onSuccess > Row-Update

Note we are going to have (2) columns in our row-update:

First:
Binding: TransView.FindJobMtl_AssemblySeq
Value: "{baqFindJobMtl.JobMtl_AssemblySeq}"

Second:
Binding: TransView.FindJobMtl_MtlSeq
Value: "{baqFindJobMtl.JobMtl_MtlSeq}"

This is capturing the default (first row’s) values for AssemblySeq and MtlSeq when the BAQ runs.

Save

~*~

Event #4 - RowChanged_baqDataView

This is just a simple event to capture new values if the user selects a different row in our FindJobMtl grid.

Row-update… same settings as the previous event.

Save.

Preview. At this point, you should see your slider open, and if you enter a valid material PartNum, you should see your grid populate. If you select a different row in the grid, you should also see our TransView columns update their respective values.

~*~

Event #5 - Our Form’s “OK” onClick event (the Big One!)

This is going to be a chain of event-nexts. So, we’ll set up the structure and then come back to this one to fill in the gaps.

Trigger: OnClick of your form’s “OK” button
(4) event-next(s)
Slider-Close

You can go ahead and assign the first event-next to the PerformUpdate stock event.

Save… we’ll come back to this one.

~*~

Event #6 - Execute_GetDatasetForTree (copy base and adjust)

Search for and copy the base Execute_GetDatasetForTree event.

Rename to your liking.

No Trigger.

The rest-erp is where the magic happens, and also most of the headaches.
Under Advanced > Rest Services > Method Parameters… there are (5) parameters.

I’ve had nothing but struggles in updating and have the system hold on to my changes. I highly recommend just deleting and manually recreating these one by one.

Example:
Highlight and copy the Field Name (ctrl + c):

Hit the delete (trashcan) icon.
Hit the new (+) icon.

Paste the Field Name back in (ctrl - v):

Now you can type in the Field Value and it should stick.

Repeat this as necessary. Below are the desired values:

Field Name: ipJobNum
Field Value: {KeyFields.JobNum}

Field Name: ipStartAssemblySeq
Field Value: 0

Field Name: ipCurrentAssemblySeq
Field Value: {TransView.FindJobMtl_AssemblySeq}

Field Name: ipCompleteTree
Field Value: false

Field Name: ipJobTypeMode (Does not need changed)
Field Value: MFG,PRJ,SRV (Does not need changed)

Save.

~*~

Event #7 - Refresh Tree

This one is easy enough to start from scratch, but each event action has some parameters.

New Event
Rename to your liking.
No Trigger

refresh-tree
ComponentID: jobTree
PreserveState: yes/no… your choice. I prefer no/false

dataview-filter-set
Dataview: JobAsmbl
Filter: AssemblySeq = {TransView.FindJobMtl_AssemblySeq}

row-current-set (#1)
Dataview: JobAsmbl
Row: -1

row-current-set (#2)
Dataview: JobAsmbl
Position: First

Save.

~*~

Event #8 - Filter Tree to Selected Job Mtl

This one took a bit to troubleshoot, but is very straight forward once you have things figured out.

The key thing to understand is that the Job Tree “nodes” (assemblies, materials, operations, etc.) are all tracked by SysRowIDs. These SysRowIDs are consistent with other dataviews like CurrAsm, _AllJobMtl, etc. So… we can use those dataviews to find the SysRowIDs we need, and then use those values to control where to expand the Tree.

set-tree-node-state
Preceding events already filtered our JobAsmbl dataview and that AssemblySeq (row) gets shoved into a dataview called CurrAsm. So I used that one to get the tree to open the corresponding SysRowID “node”.

Components: jobTree
SysRowID: #_trans.dataView('CurrAsm').data[0].SysRowID_#
Child Folder Entity Type: material
Is Expanded: true

dataview-condition
There’s no shortcut for the JobMtl… there’s no CurrMtl dataview or anything like that. So, I took the route of using a dataview-condition to find the matching row in the _AllJobMtl dataview that has the same AssemblySeq and MtlSeq.

The dataview-condition copies that matching row into the “matches” dataview, and I can grab the SysRowID there.

Dataview: _AllJobMtl
Result: matches
Expession: AssemblySeq = {TransView.FindJobMtl_AssemblySeq} AND MtlSeq = {TransView.FindJobMtl_MtlSeq}

The dataview-condition should only return one row. So, you’ll want to select the OnSingleMatch path here, and add your select-tree-node.

select-tree-node
Components: jobTree
SysRowID: #_trans.dataView('matches').data[0].SysRowID_#

Save.

~*~

Event #5 - Revisited

Now, go back to Event #5 (your “OK” onClick event) and plug in events 6, 7, & 8 in the (3) empty event-next(s).

Save.

~*~

Event #9 - toolFindJobMtl (BEFORE) - Optional

One last event, if you use your tool more than once, your BAQ dataview will already be populated.

This COULD actually be a nice thing… if you selected the wrong material instance the first time, you use your tool again and your form opens up with your BAQ dataview grid already populated… you can simply select a new row and click OK.

If you’d rather wipe that dataview between each tool use, you can add Event #9.

With this, before the tool event fires, the BAQ dataview is cleared so your form will always open with an empty grid.

Save.

~*~

Preview & Test

You Tree should successfully refresh to the desired Job Material:

That is awesome!

Nice Job David. First I’ve seen anyone work with tree actions on here.

FYI: Not sure if applicable but there are a few (undocumented) special args in the expression evaluator which I believe relate to the current tree node: