Wednesday, February 19, 2014

Record Level Security AX 2009


                  Here is a sample code to retrieve the Rules that are specified for a Particular user group in AX 2009. As in table it will stores as a BLOB. The following code will return the RLS rules in JSON Format....

Just pass the AX User Group Name as a parameter...

 public str RecordLevelSecurity(str 100  Groupid)
{
        SysQueryRun queryRun;
        Query       query = new Query();
        QueryBuildRange         range;
        sysRecordLevelSecurity sys;
        int i,cnt,j=0;
        str tablename,result,id,temptablename;
        result+="{";
        while select * from sys where sys.groupId==Groupid


        if (sys.RecId)
        {
            if (sys.Restriction)
            {
                 queryRun = new SysQueryRun(sys.Restriction);
            }
            else
            {
                 query.addDataSource(sys.TabId);
                 queryRun = new SysQueryRun(query);
            }

            queryRun.saveUserSetup(false);
            queryRun.promptAllowAddDataSource(false);
            cnt = queryRun.query().dataSourceTable(sys.tabId).rangeCount();
            if(j>0)
            result+=",";

            for (i=1 ; i<=cnt; i++)
            {
                range = queryRun.query().dataSourceTable(sys.tabId).range(i);
                if(i==1)
                {
                   tablename=tableid2name(sys.tabId);
                   result+='"'+tablename+'"';
                   result+=":";
                   result+="{";
                   result+='"'+range.AOTname()+'"';
                   result+=":";
                   result+='"'+range.value()+'"';

                 }
                 else
                 {
                   result+=",";
                   result+='"'+range.AOTname()+'"';
                   result+=":";
                   result+='"'+range.value()+'"';
                 }

                 j++;

            }
            result+="}";

       }
       result+="}";

       return result;
}

AIF Queue Processing

Hi,

Here is the code to process the Inbound and Outbound requests from Queue..

InBound :-
static void ProcessInbound_Request(Args _args)
{
    ;
    // read the messages
    new AifGateWayReceiveService().run();

    // process the messages in queue
    new AifInboundProcessingService().run();

    info("done");
}

OutBound :-
static void ProcessOutbound_Request(Args _args)
{
    ;
    // process messages in queue
    new AifOutboundProcessingService().run();

    // send messages
    new AifGateWaySendService().run();

    info("done");
}