In this post I’ll show you how to use bindings together with a M3 Listpanel as well as conditions in Mashups Events to solve a scenario when you have two different M3 lists, for example one listpanel CRS610 and one listpanel MMS002 and you want to use information from thess panels to trigger a new listpanel (OIS320). If you just set up the currentItemChanged on the first two lists you will notice that either customer or item is blank depending on the list were you selected a row.
Another issue that you need to consider is if the third list requires customer and item to be selected, becuase in that case you should not trigger the list event if only one of the two is selected. To solve this requirement we need to use both bindings and event conditions.
Using a CurrentItem binding
In the Mashup Designer I recommend that you read the SDK documentation for the controls that you use in your mashups. In this example we use the ListPanel so let’s check the documentation. It is found under Help (?) -> SDK Documentation.
Once the SDK Documentation opens in a new window search for ListPanel. There will be three hits and it is the ListPanel in MForms that we are interested of.
The ListPanel has a CurrentItem property and it represents the CurrentItem which for the list is the selected row. The property returns an object but this is an object that you can use an indexer on to get a specific value. In my example I have created three ListPanels, one customerList (CRS610) och itemList (MMS002) and one priceList (OIS320). Both the customerList and the itemList have a CurrentItemChanged event and a Startup event specified. The CurrentItemChanged event will trigger the List event for the priceList. However, all values are sent in the event and the value that does not exist in the panel itself is entered as a Binding.
This gives me the following events for the customerList:
<m3:ListPanel.Events> <mashup:Events> <mashup:Event SourceEventName="Startup" TargetEventName="List"> <mashup:Parameter TargetKey="OKCONO" /> <mashup:Parameter TargetKey="OKCUNO" /> </mashup:Event> <mashup:Event SourceName="customerList" TargetName="priceList" SourceEventName="CurrentItemChanged" TargetEventName="List" Debug="True"> <mashup:Event.Conditions> <mashup:Conditions> <mashup:Condition SourceValue="{Binding ElementName=itemList, Path=CurrentItem[ITNO]}" TargetValue="" Operator="NotEqual" /> <mashup:Condition SourceValue="{Binding ElementName=customerList, Path=CurrentItem[CUNO]}" TargetValue="" Operator="NotEqual" /> </mashup:Conditions> </mashup:Event.Conditions> <mashup:Parameter TargetKey="CUNO" SourceKey="CUNO" /> <mashup:Parameter TargetKey="OTITNO" Value="{Binding ElementName=itemList, Path=CurrentItem[ITNO]}" /> </mashup:Event> </mashup:Events> </m3:ListPanel.Events>
The key note here is the binding for the TargetKey=”OTITNO”, the value is set to a standrad WPF Binding. The elementName is the name of the ListPanel that has items, itemList and the selected row is the CurrentItem property and you use the indexer [fieldName], to get a specific value. And since the priceList requires ITNO I need to set it in the event. The other list has the same events but binds in customer instead.
I have two lists and when I click one list both customer and item are delivered to the priceList, that is if both lists have a selection. The first time I select a customer, there is not item selected and then item is empty. What if I only want to trigger the List event on the priceList if both customer and item is selected?
This is were Event Conditions come in handy.
Event Conditions
Event conditions can be very useful and there is a pretty cool example on it found in the Mashup Designer under Help -> Common Controls -> Condition. If you haven’t played around with all the examples you definately should do that.
I only want to trigger List on the priceList when there is a value for both customer and item. So I add a condition on the CurrentItemChanged event for both of my lists.
This is what the XAML looks like. In this case I use bindings for both, but I could have used SourceKey for the value that is available in that panel.
<mashup:Event SourceName="customerList" TargetName="priceList" SourceEventName="CurrentItemChanged" TargetEventName="List" Debug="True"> <mashup:Event.Conditions> <mashup:Conditions> <mashup:Condition SourceValue="{Binding ElementName=itemList, Path=CurrentItem[ITNO]}" TargetValue="" Operator="NotEqual" /> <mashup:Condition SourceValue="{Binding ElementName=customerList, Path=CurrentItem[CUNO]}" TargetValue="" Operator="NotEqual" /> </mashup:Conditions> </mashup:Event.Conditions> <mashup:Parameter TargetKey="CUNO" SourceKey="CUNO" /> <mashup:Parameter TargetKey="OTITNO" Value="{Binding ElementName=itemList, Path=CurrentItem[ITNO]}" /> </mashup:Event>
In order to this mashup to work the user must have selected to accept the terms of price simulation in OIS320/P. I have not managed to set this value on the Bookmark.
This is the final result:
Here is the complete XAML.
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ui="clr-namespace:Mango.UI.Controls;assembly=Mango.UI" xmlns:mashup="clr-namespace:Mango.UI.Services.Mashup;assembly=Mango.UI" xmlns:m3="clr-namespace:MForms.Mashup;assembly=MForms"> <Grid.Resources> <mashup:ShowMessage x:Key="ShowMessage" /> </Grid.Resources> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition Height="*" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <m3:ListPanel Name="customerList"> <m3:ListPanel.Events> <mashup:Events> <mashup:Event SourceEventName="Startup" TargetEventName="List"> <mashup:Event.Conditions> <mashup:Conditions> <mashup:Condition /> </mashup:Conditions> </mashup:Event.Conditions> <mashup:Parameter TargetKey="OKCONO" /> <mashup:Parameter TargetKey="OKCUNO" /> </mashup:Event> <mashup:Event SourceName="customerList" TargetName="priceList" SourceEventName="CurrentItemChanged" TargetEventName="List" Debug="True"> <mashup:Event.Conditions> <mashup:Conditions> <mashup:Condition SourceValue="{Binding ElementName=itemList, Path=CurrentItem[ITNO]}" TargetValue="" Operator="NotEqual" /> <mashup:Condition SourceValue="{Binding ElementName=customerList, Path=CurrentItem[CUNO]}" TargetValue="" Operator="NotEqual" /> </mashup:Conditions> </mashup:Event.Conditions> <mashup:Parameter TargetKey="CUNO" SourceKey="CUNO" /> <mashup:Parameter TargetKey="OTITNO" Value="{Binding ElementName=itemList, Path=CurrentItem[ITNO]}" /> </mashup:Event> </mashup:Events> </m3:ListPanel.Events> <m3:ListPanel.Bookmark> <m3:Bookmark Program="CRS610" Table="OCUSMA" KeyNames="OKCONO,OKCUNO" /> </m3:ListPanel.Bookmark> </m3:ListPanel> <m3:ListPanel Name="itemList" Grid.Column="1"> <m3:ListPanel.Events> <mashup:Events> <mashup:Event SourceEventName="Startup" TargetEventName="List"> <mashup:Parameter TargetKey="MBCONO" /> <mashup:Parameter TargetKey="MBWHLO" /> <mashup:Parameter TargetKey="MBITNO" /> </mashup:Event> <mashup:Event SourceName="itemList" TargetName="priceList" SourceEventName="CurrentItemChanged" TargetEventName="List" Debug="True"> <mashup:Event.Conditions> <mashup:Conditions> <mashup:Condition SourceValue="{Binding ElementName=itemList, Path=CurrentItem[ITNO]}" TargetValue="" Operator="NotEqual" /> <mashup:Condition SourceValue="{Binding ElementName=customerList, Path=CurrentItem[CUNO]}" TargetValue="" Operator="NotEqual" /> </mashup:Conditions> </mashup:Event.Conditions> <mashup:Parameter TargetKey="OTCUNO" Value="{Binding ElementName=customerList, Path=CurrentItem[CUNO]}" /> <mashup:Parameter TargetKey="OTITNO" SourceKey="MBITNO" /> </mashup:Event> </mashup:Events> </m3:ListPanel.Events> <m3:ListPanel.Bookmark> <m3:Bookmark Program="MMS002" Table="MITBAL" KeyNames="MBCONO,MBWHLO,MBITNO" /> </m3:ListPanel.Bookmark> </m3:ListPanel> <m3:ListPanel Name="priceList" Grid.Row="1" Grid.ColumnSpan="2"> <m3:ListPanel.Bookmark> <m3:Bookmark Program="OIS320" Table="OOI320" KeyNames="OTCONO,OTCUNO,OTITNO,OTDWDT,OTQTLB,OTNETP,OTFVDT,OTDIPO,OTAGNO,OTAGLN,OTPRRF,OTPIDE" /> </m3:ListPanel.Bookmark> </m3:ListPanel> <ui:StatusBar Name="StatusBar" Grid.Row="2" Grid.ColumnSpan="2" Grid.Column="0" /> </Grid>
Hi, we are trying to create a mashup for sales. In panel 1 we search and select 1 customer. This opens up different tabs in panel 2, for example ‘open order lines’ (OIS301). The next panel we want to show the status of the linked manufacturing orders (how much has already been manufactured,.. PMS100 view. So as a link between panel 2 (customer order lines) and panel 3 (production status) we have the reference order nr and a default value for the reference order categorie = 3. I created a sorting order for PMS100 which already has a filter on reference order and ref order line. In the event for panel 3 production order status I used ‘currentitemchange’ and source = customer order lines, then filled in the source keys ORNO and PONR for target keys RORN and RORL but this does not work. I also tried it using OBKV (instead of order nr).. Can’t get any value in the filters of reference order nr, ref order ln when changing panel 2. The panel of PMS100 is shown but with blank filters. I can fill in the order nr and orderln number manually and then it works fine. Can you tell me what I ‘ m doing wrong, if I should use the conditions, default values instead to get the filters filled with the value of panel 2? Thanks for your reply
Hi, I’m not sure I completely understand your scenario. Have you used debug=true on the event that you are setting up? The condition in my example above is just so that the two list don’t trigger the events independently if there is a selection or not. If you could to a simple repro of your mashup it would be easier. Perhaps a link to a SkyDrive or some other online resource. Try and add a code /code XML tag in the comment and include the XAML within that block – it’s like an XML element node.
Your xaml here
Don’t use default values unless you should have that value if the panel does not contain any value. You could try and add bindings to a textblock to show values.
What version are you one? The CurrentItem was added in one version – I’m not sure which one.
Hi Karin, thanks for your reply. I managed to get the link now, added an extra start event and source key and now it works fine with the filter. We are on version 9.1.3.0.0 for mashup designer. Now trying to get the detail screen of PMS101 starting from the PMS100 ‘currentitemchange’ event but it is not so easily done apparantly.
Hi,
Nice to hear that the first thing was sorted out. As for the PMS100 to PMS101 connection you start with having the debug=true. Also note that if source and target keys are the same it is enough to have the target key. And in many cases the short name is enough. Like CUNO instead of OBCUNO or whatever.
I’m not familiar with those specific programs. You have to check that all required fields are avaialble in the first panel.
Good Luck!
Do you know how to bind a value from the first line of M3 list panel even if this line is not selected ?
Hi,
I would be possible to get the value using code but it is not possible to get it in a mashup since there is no CurrentItem selected. It is possible to select the first row with javascript and we might even have added a property on the panel to autoselect – but no there is no way to bind to the list directly.