Thursday, 20 March 2014

In Memory - SSRS reports

ProdCalcTransVarianceDP
===================

Once values are inserted to table, i need to modify and then update to table.

Since in report the temp table is 'Inmemory ' , the ProdCalcTransVarianceDP is applied to only one selected Prodid.

But my requirement is to get all ProdId's if prodid is not selected.
Modified , to  my requirment

/// <summary>
///    The <c>CitProdCalcTransVarianceSumryDP</c> class is the Report Data Provider class for the
///    <c>CitProdCalcTransVarianceSumry</c> report.
/// </summary>
/// REM 3/12/14 - CIT_245_VarianceSummaryReport
[SRSReportParameterAttribute(classStr(CitProdCalcTransVarianceSumryContract)),
 SRSReportQueryAttribute(queryStr(CitProdTableProdCalcTrans))]
class CitProdCalcTransVarianceSumryDP extends SRSReportDataProviderBase
{
    TmpProdStandardVariance         tmpProdStandardVariance;
    TmpProdStandardVariance         tmpProdStandardVarianceAll;
    ProdStandardVariance            prodStandardVariance;
}
private InventItemPrice getItemPrice(ProdTable prodTable)
{
    InventItemPrice inventItemPrice;
    InventCostTrans inventCostTrans;

    select firstonly TableId from inventCostTrans
        where inventCostTrans.InventTransId     == prodTable.InventTransId
            && inventCostTrans.CostTransType     == InventCostTransType::Receipt
            && inventCostTrans.CostTransState    == InventCostTransState::Financial
            && inventCostTrans.CostTransRefType  == InventCostTransRefType::Production
    join inventItemPrice
        where inventItemPrice.RecId == inventCostTrans.ItemPriceRefRecId;

    return inventItemPrice;
}

/// <summary>
/// Retrieves data from the <c>TmpProdStandardVariance</c> table.
/// </summary>
/// <returns>
/// Data from the <c>TmpProdStandardVariance</c> table.
/// </returns>
[SRSReportDataSetAttribute(tableStr(TmpProdStandardVariance))]
public TmpProdStandardVariance getTmpProdStandardVariance()
{
    select tmpProdStandardVarianceAll
        order by CalcType asc, CostGroupId asc
        where tmpProdStandardVarianceAll.InventCostLevel <= InventCostLevel::Single;

    return tmpProdStandardVarianceAll;
}

         private CostAmount getTotalVariance()
{
    TmpProdStandardVariance totalStandardVariance;

    totalStandardVariance.setTmpData(tmpProdStandardVarianceAll);
    select firstonly totalStandardVariance
        where totalStandardVariance.CalcType == ItemCalcType::Production;

    return totalStandardVariance.totalVariance();
}

         public void new(ProdStandardVariance _prodStandardVariance = ProdStandardVariance::construct(ProdTransRefType::Production))
{
    super();
    prodStandardVariance = _prodStandardVariance;
}

/// <summary>
/// Fetches the required data for the report.
/// </summary>
[SysEntryPointAttribute]
public void processReport()
{

    InventItemPrice         inventItemPrice;

    CitProdCalcTransVarianceSumryContract contract = this.parmDataContract() as CitProdCalcTransVarianceSumryContract;
    ProdTable               prodTable;
    CostAmount              totalVariance;
    //REM ->
    Query                   query = this.parmQuery();
    QueryRun                queryRun;
    ProdCalcTrans           prodCalcTransLoc;
    RecId                   recidCount = 1;
    //REM <-
    ;

    prodStandardVariance.citSetCalledFromVarianceSummaryReport(true); //REM
    queryRun = new QueryRun(query); //REM

    while (queryRun.next()) //REM
    {
        prodTable = queryRun.get(TableNum(prodTable));
        prodCalcTransLoc = queryRun.get(TableNum(prodCalcTrans));

        InventItemPrice = this.getItemPrice(prodTable);
        prodStandardVariance.calc(prodTable.ProdId,
                                  ProdTransRefType::Production,
                                  prodTable.CollectRefLevel,
                                  prodTable.CollectRefProdId,
                                  prodTable.RealDate);

        tmpProdStandardVariance.setTmpData(prodStandardVariance.parmTmpProdStandardVariance()); //Retrieve record set from class
        totalVariance = this.getTotalVariance();

        while select tmpProdStandardVariance
        {
            tmpProdStandardVariance.CitProdId = prodTable.ProdId;
            tmpProdStandardVariance.CitItemId = prodTable.ItemId;
            tmpProdStandardVariance.CitItemName = prodTable.itemName();
            tmpProdStandardVariance.CitDateEnded = prodCalcTransLoc.TransDate; //Date ended on 'Production' type record

            if (inventItemPrice.PriceCalcId)
            {
                tmpProdStandardVariance.LotSize = BOMCalcTable::find(inventItemPrice.PriceCalcId).Qty;
            }
            else
            {
                tmpProdStandardVariance.LotSize = inventItemPrice.PriceUnit;
            }
            tmpProdStandardVariance.TotalVarianceValue = totalVariance;
            tmpProdStandardVariance.ReportedGood = prodTable.reportedFinishedGood();
            tmpProdStandardVariance.update();

            //Insert all records in buffer into temp table used by report ->
            tmpProdStandardVarianceAll.data(tmpProdStandardVariance);
            tmpProdStandardVarianceAll.RecId = recidCount;
            recidCount ++;

            tmpProdStandardVarianceAll.insert();
            //Insert all records in buffer into temp table used by report <-
        }
    }
}

Wednesday, 12 March 2014

AIF

outbound services - triggered by AX or run by user, by batch process. Ex : whenever user posts picking list then i need to

send the xml.

Inbound - based on request AIF responds to it

Response - outbound * asynchronous
request and response - in adn outbound

Tools>> Application integration >> AIFDocumentService >> AIFCreate Document Service.

Rc on service >> Addins >> register service.
DO CIL
Then go to System Administraion >> setup >> service administraion integreation framework >> Inbound

NetTcp ( Adapter)

Service operations  ( add all the services methods to left pannel, Data policies ( enable all)

search - VS coomand  -
wcftestclient  >> enter

RC Add service >> , Paste teh WCF service operation.

Click any methods.

Select - find - Leave Call context - null
        Query criteria- Querycriteria
        Criteria Element - lenght -1
        DataSource name  - custtable
Fieldname , Operator - equal, value1 - give some value.

Create - Sender iD - USMF ( Company name)
    Class - entity... Mandatory while creating ( else throw error)


Check - Start new proxy Check  >> Click Invoke.

Monday, 10 March 2014

how to enable or disable security policy through code.

http://daxdilip.blogspot.in/2013/03/issue-with-security-policy-in-dynamics.html

 have found a workaround, by taking a different approach to the scenario and instead of attaching the Security Policy to the Role directly, I changed the ContextType to “ContextString” from the previously defined “Rolename” and put a ContextString called “DNTestSec”.
(Step 1)


I then attached this ContextString to the role and query. (Please see below Step 2 and Step 3)

After making this changes, the below code makes sense, as it can enable/disable security at run-time because it can find the ContextSecurity string. (Below is a standard ax code which you can find in one of the DirParty* forms in AOT)


{
    #DirParty
    XDSServices xds = new XDSServices();

 // Trigger the Dirparty table XDS  policies by passing the context string 
   xds.setXDSContext(0, #RestrictParty);
  super();

 // Disable the Dirparty XDS policy by passing a blank context string .

   xds.setXDSContext(0, ' ');
}

Sunday, 2 March 2014

Jobs on security

static void SecurityByRole(Args _args)
{

    SecurityRole securityRole;

    SecurityUserRole UserRole;

    SysUserInfo  userInfo;

    OMUserRoleOrganization roleOrganization;

    OMInternalOrganization internalOrganization;

    while select ID from userInfo

        order by id asc

        outer join UserRole

        where UserRole.User == userInfo.Id

            outer join securityRole

            where securityRole.RecId == UserRole.SecurityRole

            outer join roleOrganization

            where roleOrganization.User == userInfo.Id

            && roleOrganization.SecurityRole == UserRole.SecurityRole

                outer join internalOrganization

                    where internalOrganization.RecId == roleOrganization.OMInternalOrganization

        {

            print userInfo.Id, userInfo.Email, SysLabel::labelId2String(securityRole.Name), internalOrganization.Name ? internalOrganization.Name : "All Company";

           // pause;

    }

pause;

}