How to check if a JScript is running in a Mashup

In some cases you want your JScript to react to the fact that it is part of an Mashup.

This is the way to do it up to version 9.1.3:


import System;
import System.Windows;
import System.Windows.Controls;
import MForms;
import Mango.UI.Utils;

package MForms.JScript {
   class MashupTestCurrentVersion {
      public function Init(element: Object, args: Object, controller : Object, debug : Object) {

         if(controller.RenderEngine.ListControl != null)
            if(IsMashup(controller.RenderEngine.ListControl.ListView)) {
               MessageBox.Show("Running in a Mashup");
            } else {
               MessageBox.Show("Not running in a Mashup");

      private function IsMashup(element : Object) {
         var type = Type.GetType("Mango.UI.Services.Mashup.MashupInstance,Mango.UI");
         return Helpers.FindParent(element, type) != null;

Thanks to Peter for the code.

12 thoughts on “How to check if a JScript is running in a Mashup

  1. thibaudatwork

    Hi Karin, thanks for the tip!! I have a question. How can we add a script to a Mashup? I can successfully create a script in an M3 program (for example: CRS610/E) that adds a button to the panel (for example next to the telephone field). The script works fine when run from the program itself (CRS610/E). I then created a Mashup that reuses that panel and that telephone field. However, the script doesn’t execute from the mashup, I don’t see the button. Any idea? Thanks!!

    1. karinpb Post author

      As long as the M3Mashup is a standard view of CRS610/E and not a custom layout with fields from different panels the script should run. Scripts are disabled when you use fields from different panels so perhaps this is the issue that you are seeing.
      What is the layout mode?

  2. Pingback: How to check if a JScript is running in a Mashup « M3 ideas

  3. Pingback: Selecting the first row in a M3 list to trigger CurrentItemChanged « Developing for Lawson Smart Office

    1. karinpb Post author

      You would have to find the Runner or Task for your host and check the URI. I would have to check the API documentation. I’ll try and give you a more precise answer next week.

  4. Pingback: How to tell Mashups apart in a Smart Office script « M3 ideas

  5. Sam N

    Hi ,
    I have been trying to use a MessageBox like this

    MessageBox.Show (“You must enter a name.”, “Name Entry error”, MessageBoxButtons.YesNo, MessageBoxIcon.Information);

    I get the below error when I try to compile it.

    error JS1183: More than one method or property matches this argument list

    Have you seen an example of a dialog box or yes or no message box in JSCRIPT?

    Thanks Sam

    1. karinpb Post author

      You should not use the MessageBox in a script. It is too ugly. I recommend you to use our own dialogs instead. There are a bunch of them. Try and decompile Mango.UI.dll with dotPeek and look for ConfirmDialog for more examples( or check the API documentaion if you have the Smart Office SDK).

      In you case I suggest that you do the following:

      1. import Mango.UI
      2. Use ConfirmDialog.ShowAttentionDialog(“Title”, “Message”); in your script.

      It should be a warning if it is mandatory. But I would not but the word “error” in the title.

  6. Sam N

    Wow Karin . Thanks .

    I was wondering if you personally use JScript or C# for your coding needs?

    1. karinpb Post author

      Hi Sam,
      I’m in the team developing Smart Office so I code a lot of C# and XAML. I have done some JScripts but it is mostly to help people out and never for my own needs (and for the M3 internals I have to ask “norpe” since he is the MForms expert).

      There are only two “standard” JScripts that we from development release as part of M3 UI Adapter (M3 server part). But I code a lot in Java and Web (JavaScript, JQuery, TypeScript) as well even though I like .Net the most.

      If I had to do a lot of script I would rather call into .Net code and code a feature or dll simply becuase you can then debug everything in Visual Studio – and write in C#.

Comments are closed.