web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Pass values into parameters of .net assembly which access from service enabled Procedure in Dexterity

(1) ShareShare
ReportReport
Posted on by

I have used .net assembly in my procedure. This .net assembly contains fields of a customized table in GP and i have added it to libraries in Dexterity and included it in my service enabled procedure. I need to retrieve all the records of relevant as a list, in the same way it used in standard services.

Ex - 

https://MachineName:Port/GPService/Tenants(DefaultTenant)/Companies(Fabrikam,%20Inc.)/Inventory/Items

I'm new to GP development and my problem is now to pass values into this assembly properties. If anyone can guide, it will great pleasure to me. Please find below sanscript code I have done so far. 

-----------------------------------------------------------

using Test.Object; //assembly I have created and already added it into library
using System.Collections;//windows assembly and added it to library

out System.Collections.Generic.List<Test.Object> TestList; // out parameter
local Item Test; //'Item' is a class which defined under Test.Object dll file

get first table Test_Item; 
while err() <> EOF do
// I need to add table records into TestList variable, where I've no idea how to.

get next table Test_Item;
end while;

-----------------------------------------------------------

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    A little late, I know, but, your out parameter either needs to be a List<Item>, if that's what you want to return, or your local Test variable needs to be a Test.Object.

    Assuming the latter, then, inside your while loop:

    {-----}
    Test = new Test.Object();
    Test.TestField = 'Test Field' of table Test_Item;
    Test.TestField2 = 'Test Field 2' of table Test_Item;
    TestList.Add(Test);
    {-----}

    Also, don't forget to initialize the out parameter or you will get an NullReferenceException:

    TestList = new List<Test.Object>();

  • Suggested answer
    MG-16101311-0 Profile Picture
    26,225 on at

    Try this:

    using Test.Object;
    using System.Collection.Generic;
    
    out List<Item> ItemList;
    
    
    local TraceStart  Trace;
    local integer     nStatus;
    local integer     iCurrentCount = 0;
    
    local Item        ItemObj;
    local long        nLimit = GetQueryStringParameterLimit();
    local boolean     fSummary = GetQueryStringParameterFormat();
    
    
    ItemList = new List<Item>();
    
    nStatus = Create(Trace) of form Trace;
    nStatus = AssignTraceReference(Trace);
    
    call Trace of form Trace, Trace, OKAY, technicalname(script yourServiceProc, QUALIFY_FULL), getmsg(12667 {=Enter Method});
    
    clear table Test_Item;
    range clear table Test_Item;
    
    get first table Test_Item;
    while (iCurrentCount < nLimit) and (err() = OKAY) do
      ItemObj = new Item();
      ItemObj.YourField1 = Field1 of table Test_Item;
      ItemObj.YourField2 = Field2 of table Test_Item;
      { and so on }
    
      ItemList.Add(ItemObj);
      get next table Test_Item;
      increment iCurrentCount;
    end while;  
    
    call Trace of form Trace,Trace,OKAY,technicalname(script YourServiceProc, QUALIFY_FULL), getmsg(12668);  {Exit method.}
    
    

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

#1
Dan Liebl Profile Picture

Dan Liebl 2

#2
Shravan Attelli Profile Picture

Shravan Attelli 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans