Sunday, July 3, 2016

Call Web form Web service to do changes in Web form from AX 2012

static void CallWebService(Args _args)
{
    ClrObject                                                   clientType;
    Library.EPGServiceRefrence.BranchLevelTransferClient     ServiceClient;
    Library.EPGServiceRefrence.UserAccount                   userCredentials;
    Library.EPGServiceRefrence.eFormTransaction               eformTransactionReturn;
    System.Exception                                            ex;
    Name                                                        eformCode,StatusMessage;
    ;
    try
    {
        new InteropPermission(InteropKind::ClrInterop).assert();
        clientType              = CLRInterop::getType("EPGLibrary.EPGServiceRefrence.BranchLevelTransferClient");
        ServiceClient           = AifUtil::createServiceClient(clientType);
        userCredentials= new EPGLibrary.EPGServiceRefrence.UserAccount();
        userCredentials.set_UserId("epgadminuser");
        userCredentials.set_Password("epgadminuser");
        eformTransactionReturn = ServiceClient.UpdateBranchTransferFlag(00012,"wrongcode",userCredentials);
        StatusMessage=eformTransactionReturn.get_StatusMessage();
        if(eformTransactionReturn.get_SuccessFlag())
            info("Branch Trasnfer:"+StatusMessage);
        else
            error("Error Branch Transfer: "+StatusMessage);

        eformTransactionReturn = ServiceClient.UpdateLevelTransferFlag(00012,"wrongcode",userCredentials);
        StatusMessage=eformTransactionReturn.get_StatusMessage();
        if(eformTransactionReturn.get_SuccessFlag())
            info("Class Trasnfer: "+StatusMessage);
        else
            error("Error Class Transfer: "+StatusMessage);

         eformTransactionReturn = ServiceClient.CreateReversalVoucher(00012,userCredentials);
        StatusMessage=eformTransactionReturn.get_StatusMessage();
        if(eformTransactionReturn.get_SuccessFlag())
            info("Vocher Reverse:"+StatusMessage);
        else
            error("Error Voucher Reverse:"+StatusMessage);
        ServiceClient.Close();
    }
    catch(Exception::CLRError)
    {
        if(ServiceClient)
            ServiceClient.Close();
        ex = CLRInterop::getLastException();
        error(ex.ToString());
    }
}

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...