Start a Mashup with input parameters

Here is the solution to start a Mashup in Lawson Smart Office with input parameters.

  1. Suppose we have a Mashup located at:
    C:\Test.xaml

  2. The URI to launch that Mashup in Smart Office would be:
    mashup:///?BaseUri=C:\&RelativeUri=Test.xaml

  3. To send a key:value pair as an input parameter to the Mashup we add the parameter DefaultValues to the URI with an arbitrary key and an arbitrary value separated by a colon. In this example I chose a key InputParameter with a value Hello World! and I URI-encoded them:
    DefaultValues=InputParameter:Hello+World!
  4. The resulting URI is:
    mashup:///?BaseUri=C:\&RelativeUri=Test.xaml&DefaultValues=InputParameter:Hello+World!
  5. In the Mashup we receive the value with the following Binding:
    {Binding Converter={StaticResource CurrentItemValue}, ConverterParameter=InputParameter, Mode=OneTime}
  6. We can show the value in a TextBox for example:
    <TextBox Text="{Binding Converter={StaticResource CurrentItemValue}, ConverterParameter=InputParameter, Mode=OneTime}" Grid.Column="1" />
  7. For that Binding to work we must add the converter Mango.UI.Services.Mashup.CurrentItemValue to our Grid.Resources:
    <Grid.Resources>
    	<mashup:CurrentItemValue x:Key="CurrentItemValue" />
    </Grid.Resources>
  8. Now let’s start the URI:
  9. Here’s the result, the input parameter is shown in the TextBox!
  10. We can also send multiple input parameters by separating the key:value pairs with semi-colons:
    InputParameter1:Hello+World!;InputParameter2:Yeehaa!;InputParameter3:ABC123
  11. The new URI is:
    mashup:///?BaseUri=C:\&RelativeUri=Test2.xaml&DefaultValues=InputParameter1:Hello+World!;InputParameter2:Yeehaa!;InputParameter3:ABC123
  12. The new result is:

Here is a screenshot of the final XAML in the Mashup Designer:

Here is the complete XAML source code:

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" Margin="10">

This solution was given by the following sample provided in the Mashup Designer:

That’s it!

UPDATE 2013-01-31:

Note 1: My example above showed the URI to start a Mashup from the C:\ drive and folder. But to start a Mashup that is deployed, the BaseUri must point to the *.mashup file, for example: mashup:///?BaseUri=MyMashup.mashup&RelativeUri=MyMashup.xaml&DefaultValues=key1:value1;key2=value2 . This will work with a Mashup deployed either privately (Mashup Designer > Deploy > Private), either locally (Smart Office > Show > My Local Applications). But for a Mashup deployed globally (LifeCycle Manager > Admin View > Install) you must prefix the BaseUri with the folder Mashups\, for example: mashup:///?BaseUri=Mashups\MyMashup.mashup&RelativeUri=MyMashup.xaml&DefaultValues=…

Note 2: We can create a Shortcut in Smart Office (for example, CRS610 > Tools > Personalize Shortcuts) and dynamically get values from the current panel by putting the field name in curly braces (angle brackets will work as well), for example: mashup:///?BaseUri=MyMashup.mashup&RelativeUri=MyMashup.xaml&DefaultValues=ItemNumber:{ITNO}

Published by

thibaudatwork

M3 Technical Consultant

10 thoughts on “Start a Mashup with input parameters”

  1. I tried to pass parameter from jscript to mashup.

    I want to run MIList when the mashup is loading. but It is not working . but I have added button , it is working fine .

    I want to call API without button .

    may mashup URl is

    mashup:///?BaseUri=popup.mashup&RelativeUri=popup.xaml&DefaultValues=InputParameter1:200;InputParameter2:ARA09145;MashupControlName:popup;

    mashup code :

    <Grid.Resources>

    </Grid.Resources>

    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
       <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <StackPanel Orientation="Horizontal" Margin="8,16,8,8">
    <TextBox Name="CompanyTextBox" Width="200" Margin="0" />
    <TextBox Name="SupplierTextBox" Width="200" Margin="0" />
    <Button Content="{mashup:Constant Key=Search,File=Mango.UI}" Width="100" VerticalAlignment="Center" Margin="8,0,5,0">
            <Button.CommandParameter>
                <mashup:Events>
                    <mashup:Event SourceEventName="Click" TargetName="CustomerList" TargetEventName="List">
                        <mashup:Parameter TargetKey="CUNO" Value="{Binding Converter={StaticResource CurrentItemValue}, ConverterParameter=InputParameter1, Mode=OneTime}" />
                        <mashup:Parameter TargetKey="SUNM" Value="{Binding Converter={StaticResource CurrentItemValue}, ConverterParameter=InputParameter2, Mode=OneTime}" />
                    </mashup:Event>
                </mashup:Events>
            </Button.CommandParameter>
        </Button>
    </StackPanel>
    
    
    
    <m3:MIListPanel Name="CustomerList" Margin="8" Grid.Row="1">
        <m3:MIListPanel.Events>
            <mashup:Events>
                <mashup:Event SourceEventName="Startup" TargetEventName="List">
    
                        <mashup:Parameter TargetKey="CUNO" Value="{Binding Converter={StaticResource CurrentItemValue}, ConverterParameter=InputParameter1, Mode=OneTime}" />
                        <mashup:Parameter TargetKey="SUNM" Value="{Binding Converter={StaticResource CurrentItemValue}, ConverterParameter=InputParameter2, Mode=OneTime}" />
                    </mashup:Event>
    
            </mashup:Events>
        </m3:MIListPanel.Events>
        <m3:MIListPanel.DataSource>
            <m3:MIDataSource Program="CRS620MI" Transaction="LstByName" Type="List" InputFields="CUNO,SUNM" OutputFields="CONO,SUNO,SUTY,SUNM,ALSU,STAT" MaxReturnedRecords="200" />
        </m3:MIListPanel.DataSource>
        <ListView ItemsSource="{Binding Items}" Style="{DynamicResource styleListView}" ItemContainerStyle="{DynamicResource styleListViewItem}">
            <ListView.View>
                <GridView ColumnHeaderContainerStyle="{DynamicResource styleGridViewColumnHeader}">
                    <GridView.Columns>
                        <GridViewColumn Header="Company" DisplayMemberBinding="{Binding [CONO]}" />
                        <GridViewColumn Header="Suppliernumber" DisplayMemberBinding="{Binding [SUNO]}" />
                        <GridViewColumn Header="Suppliertype" DisplayMemberBinding="{Binding [SUTY]}" />
                        <GridViewColumn Header="Suppliername" DisplayMemberBinding="{Binding [SUNM]}" />
                        <GridViewColumn Header="Searchkey" DisplayMemberBinding="{Binding [ALSU]}" />
                        <GridViewColumn Header="Status" DisplayMemberBinding="{Binding [STAT]}" />
                    </GridView.Columns>
                </GridView>
            </ListView.View>
        </ListView>
    </m3:MIListPanel>
    
    
    
    
    
    <ui:StatusBar Name="StatusBar" Grid.Row="3" Grid.Column="0" />
    

    please help me .

    Thank you

    Like

    1. Hi Priyantha, I think there is a trick. I don’t remember well, but I think the problem is that the Startup event is executed before the converters or variable substitutions or something like that. The workaround I think is to make the variable substitution not in the event but in a hidden TextBox somewhere prior to the MIListPanel; then in the event you pull from the TextBox. It was a long time and I don’t remember where my example is on my hard disk. /Thibaud

      Like

    1. I found a sample Mashup that I developed some time ago and that worked. I did some new tests just now and the trick doesn’t work anymore. I’m not sure what’s going on. Maybe this new version of Smart Office doesn’t support that? I suggest you ask your question in Infor Xtreme.

      Like

    1. Priyantha,

      It just happens that I need this for one of my customers right now, so I did some more tests, and here is what I found:

      1) In the URL for DefaultValues, I must use the M3 field name, like CUNO, instead of whatever field name I was using before, like CustomerNumber. For instance, the following will work &DefaultValues=CUNO:123 whereas the following &DefaultValues=CustomerNumber:123 will leave the customer field blank.

      2) The following has no influence, so I removed it: Grid.Resources mashup:CurrentItemValue x:Key=”CurrentItemValue”

      3) The following has no influence, so I removed it: {Binding Converter={StaticResource CurrentItemValue}, ConverterParameter=CUNO, Mode=OneTime}

      Hope it helps,

      Thibaud

      Like

  2. Dear Thibaud,

     it is working . thank you ....
    

    <Grid.Resources>
    </Grid.Resources>

    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="1*" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="1*" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    
    <m3:MIListPanel Name="SupplierList" Margin="8" Grid.Row="0" Grid.Column="0">
        <m3:MIListPanel.Events>
            <mashup:Events>
                <mashup:Event TargetName="SupplierList" SourceEventName="Startup" TargetEventName="List">
                    <mashup:Parameter SourceKey="CONO" />
                    <mashup:Parameter SourceKey="SUNM" />
                </mashup:Event>
            </mashup:Events>
        </m3:MIListPanel.Events>
        <m3:MIListPanel.DataSource>
            <m3:MIDataSource Program="CRS620MI" Transaction="LstByName" Type="List" InputFields="CONO,SUNM" OutputFields="CONO,SUNO,SUTY,SUNM,ALSU,STAT" MaxReturnedRecords="200" />
        </m3:MIListPanel.DataSource>
        <ListView ItemsSource="{Binding Items}" Style="{DynamicResource styleListView}" ItemContainerStyle="{DynamicResource styleListViewItem}">
            <ListView.View>
                <GridView ColumnHeaderContainerStyle="{DynamicResource styleGridViewColumnHeader}">
                    <GridView.Columns>
                        <GridViewColumn Header="Company" DisplayMemberBinding="{Binding [CONO]}" />
                        <GridViewColumn Header="Suppliernumber" DisplayMemberBinding="{Binding [SUNO]}" />
                        <GridViewColumn Header="Suppliertype" DisplayMemberBinding="{Binding [SUTY]}" />
                        <GridViewColumn Header="Suppliername" DisplayMemberBinding="{Binding [SUNM]}" />
                        <GridViewColumn Header="Searchkey" DisplayMemberBinding="{Binding [ALSU]}" />
                        <GridViewColumn Header="Status" DisplayMemberBinding="{Binding [STAT]}" />
                    </GridView.Columns>
                </GridView>
            </ListView.View>
        </ListView>
    </m3:MIListPanel>
    <ui:StatusBar Name="StatusBar" Grid.Row="1" Grid.Column="0" />
    

    mashup:///?BaseUri=popup.mashup&RelativeUri=popup.xaml&DefaultValues=CONO:200;SUNM:ARA09145;MashupControlName:popup;

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s