Skip to main content

Dynamics GP- How to use custom .Net assembly in Dexterity

Let's take a scenario that we need to develop as dexterity script using a .net assembly/DLL program inside the Dexterity script itself.

We have to create the assembly/DLL which we need to use or else use from .net framework.


  1. In Visual Studio we have to create a class library project. Provide Name as you want in your project. In my case, i have given the name as MyAssembly.
  2. Add a new class to the project. Make sure that the access modifier of that class is public.Also, define public properties you need to access from the Dexterity script.                             public class ExtraFields
    {   
       public string Description {get;set;}
       public List<Field> FieldList = new List<Field>();
    }
    public class Field
    {   
       public string Id {get;set;}
       public string Value {get;set;}
    }
  3. Compile your project.
  4. In order to use this assembly program in your Dexterity script, you have to install that to Global Assembly Cache(GAC). Refer this to know How to Install an Assembly in the GAC
  5. Then you have to refer that to the dexterity libraries.
  6. Use that in the dexterity script.                                            using MyAssembly;
    using MyAssembly.ExtraFields;
    using System.Collections.Generic;

    local ExtraFields extraFieldsObject;
    local Field fieldObject;

    extraFieldsObject  = new ExtraFields();
    fieldObject        = new Field();

    extraFieldsObject.Description    = Your Value;

    fieldObject.Id             = Your Value;
    fieldObject.Value   = Your Value;
    extraFieldsObject.FieldList.Add(fieldObject);

    //DO YOUR WORK BELOW

Compile and run the script.


Comments

Popular posts from this blog

How to connect blob storage via Shared access signature URL (SAS)

  Follow the steps to connect the blob container using the  Shared access signature. You may need  Azure Storage Explorer    in order to access the blob storage locally. STEP 1   Under  Local & Attached   go to   Storage Accounts ( Right-click ) ->   Connect to Azure Storage . STEP 2 Select the  Blob container   option. STEP 3 Select the  Shared access signature URL (SAS)   option. STEP 4 Copy and paste the given  Blob container SAS URL   and click   Next . STEP 5 Click  Connect . You are all set to access to content of the blobs storage. 👍

How to create a PowerShell script

PowerShell    is an amazing tool which we can use to perform various operations in windows environments. Today we are going to write a  PowerShell   script using Windows  PowerShell   ISE. How to open Windows PowerShell ISE  For this session we need to have Windows  PowerShell   ISE. You can find it under,  Control Panel\All Control Panel Items\Administrative Tools. You better open Windows  PowerShell   ISE as administrator mode. if you have any issues please follow this link.  Windows PowerShell Integrated Scripting Environment (ISE) In My project I had to use  PowerShell   script to regiter few Dlls in Global Assembly Cache (GAC) and keep file paths in XML file and extract data by reading XML file. My XML file looks like this and file name is FilePath.XML . FilePath.XML <?xml version="1.0" encoding="utf-8"?> <Resource>   <MacroFilePath>\ReleaseBuild\ReleaseMacro.mac</MacroFilePath>   <ProductName>BCS</ProductN