In a production generator, I wish to display a pivot table with the following:
To visualise what goes where at our pack house, a pivot table should display Service Orders, with rows being the Pallet References (Order Lines within Purchase Orders, this indicates WHAT), and columns being be the Destinations (Delivery Addresses per Customer, this indicates WHERE). The content of the cells will be Total Colli.
I am currently getting stuck on the fact that I created a flatten ('Purchase Orders'* .’Order Lines'*), which results in a state constraint violation for ‘has reference’. Any way to work around this? Or should I restructure the application where ‘Pallets’ is a collection on its own?
application.alan
//Within 'Calender'.'Weeks'[] .'Days'[]
'Service Orders': reference-set -> downstream ^ ^ ^ ^ .'Logistics'.'Service Orders'* .'Week found'?'Yes'.'Day found'?'Yes' = inverse >'Day'
'Customers': collection ['Relation'] = union (
'' = <'Service Orders'* ^ ^ .'Sales Order'&'Relation'
) @small {
'Relation': text -> downstream ^ ^ ^ ^ ^ .'Relationship Management'.'Companies'[] = key
'Service Orders': reference-set -> downstream ^ ^ ^ ^ ^ .'Logistics'.'Service Orders'* = branch ''
'Delivery Addresses': collection ['Delivery Address'] = union (
'' = <'Service Orders'* .'Sales Order'&'Delivery Address'
) @small {
'Delivery Address': text -> ^ >'Relation'.'Addresses'[] = key
'Service Orders': reference-set -> downstream ^ ^ ^ ^ ^ ^ .'Logistics'.'Service Orders'* = branch ''
}
}
'Destinations': collection ['Destination'] = flatten (
'' = .'Customers'* .'Delivery Addresses'* as $ (
'Customer' = $ ^
'Delivery Address' = $ .'Delivery Address'
)
) join : {
'Destination': text = key
'Customer': text -> ^ .'Customers'[] = parameter
'Delivery Address': text ~> >'Customer'.'Delivery Addresses'[] = parameter
'Purchase Orders': collection ['Purchase Order'] = union (
'' = >'Delivery Address'<'Service Orders'* .'Purchase'&'Purchase Order'
) @hidden {
'Purchase Order': text -> downstream ^ ^ ^ ^ ^ ^ .'Procurement'.'Purchase Orders'[] = key
'Service Orders': reference-set -> downstream ^ ^ ^ ^ ^ ^ .'Logistics'.'Service Orders'* = branch ''
'Order Lines': collection ['Order Line'] = union (
'' = <'Service Orders'* .'Purchase'&'Purchase Order Line'
) {
'Order Line': text -> ^ >'Purchase Order'.'Order Lines'[] = key
}
}
'Pallets': collection ['POL'] = flatten (
'' = .'Purchase Orders'* .'Order Lines'* as $ (
'Purchase Order' = $ ^
'Order Line' = $ .'Order Line'
)
) join : {
'POL': text = key
'Purchase Order': text -> ^ .'Purchase Orders'[] = parameter
'Order Line': text ~> >'Purchase Order'.'Order Lines'[] = parameter
}
}
annotations.alan
handheld: 'Split' details (
title: 'Split Today'
-> inline view: .'Admin'.'Configuration'>'Current Weekday' pivot (
columns: .'Destinations': 'Delivery Address'
label: 'Destination'
cells: .'Pallets': 'Order Line' //this is not possible due to a state constraint violation for ‘has reference’
label: 'Pallet'
label: '?'
)
)
Hi Martinique,
You’ll have to make sure that the ‘cells’ collection is a collection with a key to a collection next to the ‘columns’ collection (you could call it ‘rows’). That way the system knows which ‘cells’ need to be put in the same row.
So, you will have to put the ‘flattened’ Purchase Orders / Pallets collection as the ‘rows’ collection outside of the Destinations collection and then have the ‘cells’ collection point to those rows.
Also, good to know: you can have an inline view: ‘[view name]’ that points to a view under the ‘cells’ collection, it will show up in each cell.
Rows: collection
Columns: collection
Cells collection -> ^ .'Rows'[]
// with in the handheld client annotations:
// handheld: [view name] details ( )
1 Like
Thank you Rick, that helped a lot.
The application now looks as follows.
'Pallets': collection ['POL'] = flatten (
'' = .'Purchase Orders Service'* .'Order Lines'* as $ (
'Purchase Order' = $ ^
'Order Line' = $ .'Order Line'
'Pallet Reference' = $ >'Order Line'.'Pallet Reference'
)
) join : {
'POL': text = key
'Purchase Order': text -> ^ .'Purchase Orders Service'[] = parameter
'Order Line': text ~> >'Purchase Order'.'Order Lines'[] = parameter
'Pallet Reference': text = parameter
}
'Destinations': collection ['Destination'] = flatten (
'' = .'Customers'* .'Delivery Addresses'* as $ (
'Customer' = $ ^
'Delivery Address' = $ .'Delivery Address'
)
) join : {
'Destination': text = key
'Customer': text -> ^ .'Customers'[] = parameter
'Delivery Address': text ~> >'Customer'.'Delivery Addresses'[] = parameter
'Purchase Orders': collection ['Purchase Order'] = union (
'' = >'Delivery Address'<'Service Orders'* .'Purchase'&'Purchase Order'
) @hidden {
'Purchase Order': text -> downstream ^ ^ ^ ^ ^ ^ .'Procurement'.'Purchase Orders'[] = key
'Service Orders': reference-set -> downstream ^ ^ ^ ^ ^ ^ .'Logistics'.'Service Orders'* = branch ''
'Order Lines': collection ['Order Line'] = union (
'' = <'Service Orders'* .'Purchase'&'Purchase Order Line'
) {
'Order Line': text -> ^ >'Purchase Order'.'Order Lines'[] = key
'Service Orders': reference-set -> downstream ^ ^ ^ ^ ^ ^ ^ .'Logistics'.'Service Orders'* = branch ''
}
}
'Pallets': collection ['POL'] = ^ .'Pallets'* {
'Purchase Order': text ~> ^ .'Purchase Orders'[] = >'POL'.'Purchase Order'
'Order Line': text ~> >'Purchase Order'.'Order Lines'[] = >'POL'.'Order Line'
'Match': stategroup = switch >'Order Line' (
| none => 'No' ( )
| node as $ => 'Yes' (
'Order Line' = $
)
) (
'No' { }
'Yes' {
'Order Line': text -> ^ >'Purchase Order'.'Order Lines'[] = parameter
'Total Output': number 'colli' = sum >'Order Line'<'Service Orders'* .'Total Output Colli'
'Tasks': collection ['Task'] = union (
'' = >'Order Line'<'Service Orders'* .'Tasks'* .'Task'&'Main'
) @small {
'Task': text -> ^ ^ ^ ^ ^ ^ ^ .'Configuration'.'Operations'[] = key
}
}
)
'POL': text -> ^ ^ .'Pallets'[] = key
}
}
I am now figuring out whether it is possible to display multiple display a number and a collection at the same time within the cell.
This works to display the number in the cell:
handheld: 'Split' details (
title: icon:"arrow_split", 'Split Today'
-> inline view: .'Admin'.'Configuration'>'Current Weekday' pivot (
columns: .'Destinations': 'Delivery Address'
label: .'Delivery Address'
cells: .'Pallets': 'Pallet Reference'
label: .'Pallet Reference'
label: .'Match'?'Yes'.'Total Output'
)
)
And this works to display a collection in the cell:
handheld: 'Split' details (
title: icon:"arrow_split", 'Split Today'
-> inline view: .'Admin'.'Configuration'>'Current Weekday' pivot (
columns: .'Destinations': 'Delivery Address'
label: .'Delivery Address'
cells: .'Pallets': 'Pallet Reference'
label: .'Pallet Reference'
inline view: details (
-> inline view: .'Match'?'Yes' collection (
path: .'Tasks'[] @layout: tabular
'Task': .'Task'
)
)
)
)
I am looking for syntax that enables both. Something like this:
handheld: 'Split' details (
title: icon:"arrow_split", 'Split Today'
-> inline view: .'Admin'.'Configuration'>'Current Weekday' pivot (
columns: .'Destinations': 'Delivery Address'
label: .'Delivery Address'
cells: .'Pallets': 'Pallet Reference'
label: .'Pallet Reference'
inline view: details (
-> inline view: .'Match'?'Yes' collection (
path: .'Tasks'[] @layout: tabular
'Task': .'Task'
)
-> label: .'Match'?'Yes''Total Output' // -> does not work since only text as a reference is allowed.
)
)
)
Is this possible? Any tips? Thank you in advance!
Isn’t this how you would write that?
inline view: details (
'Total Output': .'Match'?'Yes'.'Total Output'
-> inline view: .'Match'?'Yes' collection (
path: .'Tasks'[] @layout: tabular
'Task': .'Task'
)
)
1 Like
Thank you Rick!
Looking back at the documentation I see where I made my mistake. Initially I placed my Total Output after the inline view. Now I learned the sequence in which the syntax is placed is very important.
My previously attemted syntax erroneously:
inline view: details (
-> inline view: .'Match'?'Yes' collection (
path: .'Tasks'[] @layout: tabular
'Task': .'Task'
)
'Total Output': .'Match'?'Yes'.'Total Output' // -> should be before the inline view.
)
Corresponding documentation:
1 Like