Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2014
    Thanked 0 Times in 0 Posts

    How to set API data to our variables

    this coding is not working! actually it is a jscript program working in M3 software. i can fetch data from the API and display in the message but not able to display in the GRID! how can i set the addressLine2 variable to "data" in the function LoadData? it is giving the wrong out put! out put of addressLine 2 is now undefined data. but dialog box displays correct value from API of the software. i feel that i have to put loop also! because addressLine2 is having several data in it. please help:(

    import System;
    import System.Windows;
    import System.Windows.Controls;
    import MForms;
    import Lawson.M3.MI;
    import Mango.UI;
    import System.Windows.Media;
    import Mango.UI.Services.Lists;
    package MForms.JScript {
    class Test{
    public var addressLine2;

    var listView, oldCount;
    public function Init(element: Object, args: Object, controller : Object, debug : Object) {
    try {
    var listControl = controller.RenderEngine.ListControl;

    this.listView = controller.RenderEngine.ListViewControl;
    var columns = listView.View.Columns;
    var record = new MIRecord();
    MIWorker.Run("DRS100MI", "LstShipment", record, OnRunCompleted);
    var gvch = new GridViewColumnHeader();
    gvch.Content = "Forward Agent";
    var gvc = new GridViewColumn();
    gvc.Header = gvch;
    gvc.CellTemplateSelector = new ListCellTemplateSelector(columns.Count,listControl.Columns);
    var gvch2 = new GridViewColumnHeader();
    gvch2.Content = "Transport Equipement";
    var gvc2 = new GridViewColumn();
    gvc2.Header = gvch2;
    gvc2.CellTemplateSelector = new ListCellTemplateSelector(columns.Count,listControl.Columns);

    var fromRow = 0;
    var toRow = listView.Items.Count - 1;
    var newNbColumns = columns.Count;
    var lastColumnIndex = columns.Count - 1;
    // increase each row's array by one additional element
    increaseRowsArray(fromRow, toRow, newNbColumns);
    // load data in the new column of each row
    loadData(fromRow, toRow, lastColumnIndex);
    // find the ScrollViewer
    var border = VisualTreeHelper.GetChild(listView, 0);
    var grid = VisualTreeHelper.GetChild(border, 0);
    var scrollViewer: ScrollViewer = VisualTreeHelper.GetChild(grid, 3);
    // attach to the OnScrollChanged event
    } catch (ex: Exception) {

    function OnScrollChanged(sender: Object, e: ScrollChangedEventArgs) {
    try {
    if (e.VerticalChange != 0) {
    oldCount = listView.Items.Count;
    } else {
    var fromRow = oldCount;
    var toRow = listView.Items.Count - 1;
    var newNbColumns = listView.View.Columns.Count;
    var lastColumnIndex = listView.View.Columns.Count - 1;
    increaseRowsArray(fromRow, toRow, newNbColumns);
    loadData(fromRow, toRow, lastColumnIndex);
    } catch (ex: Exception) {

    Increase each row's array by one additional element.
    function increaseRowsArray(fromRow, toRow, newNbColumns) {
    var rows = listView.Items;
    for (var i = fromRow; i <= toRow; i++) {
    var row = rows[i];
    var oldArray = row.Items;
    var newArray = new String[newNbColumns];
    oldArray.CopyTo(newArray, 0);
    row.Items = newArray;
    rows.Insert(i, row);

    function loadData(fromRow, toRow, columnIndex) {
    for (var i = fromRow; i <= toRow; i++) {
    var data = "" + addressLine2; // Hello CUNO
    listView.Items[i].Items[columnIndex] = data;//I want addressLine2 value to fetched here but not working

    public function OnRunCompleted(response: MIResponse)
    { if (!response.HasError) {
    for (var record in response.Items)
    var addressLine1 = record.GetString("FWNO");

    addressLine2 = record.GetString("TRCA");// I WANT TO SET THIS VALUE to be fetched in above function loadData and in variable data

    ConfirmDialog.ShowInformationDialog(" Shipment Details", " Forward Agent- " +addressLine1 + " Transport Equipment- " + addressLine2 , null);



  2. #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,699 Times in 2,675 Posts
    That looks like Java to me. This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia! Ask a mod to move this thread to the right forum.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  3. #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,947 Times in 4,908 Posts
    That is actually JScript code, as he said.

    Microsoft, for some unholy reason, decided to support a STRANGE variant of JavaScript for server-side coding in ASP.NET.

    I doubt that there are any forums with more than a few subscribers that address this language.

    Likely the best bet is on the forums hosted by Microsoft.
    Be yourself. No one else is as qualified.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts