Dynamics 365





Showing posts with label Activate Invoice. Show all posts
Showing posts with label Activate Invoice. Show all posts

Sunday, November 17, 2019

Dynamics 365 make invoice active and Paid using C#.net code or plugin




Dynamics 365 make invoice active and Paid using C#.net code or plugin


                foreach (var item in ERPInvoices.Entities)
                {
// Set active
                    SetStateRequest setStateRequest = new SetStateRequest()
                    {
                        EntityMoniker = new EntityReference
                        {
                            Id = new Guid(item["invoiceid"].ToString()),
                            LogicalName = "invoice",
                        },
                        State = new OptionSetValue(0),

                        Status = new OptionSetValue(1)

                    };
                    _CrmService.Execute(setStateRequest);

                  // Update the field

                    Entity invoiceToUpdate = new Entity("invoice");
                    invoiceToUpdate.Id = item.Id;
                    if (issendfullyerp)
                    {
                        invoiceToUpdate.Attributes["has_issendfullyerp"] = true;
                    }
                    if (issendpartiallyerp)
                    {
                        invoiceToUpdate.Attributes["has_issendpartiallyerp"] = true;
                    }
                    _CrmService.Update(invoiceToUpdate);
//set abck paid - to old status
                    SetStateRequest request = new SetStateRequest()
                    {
                        EntityMoniker = new EntityReference
                        {
                            Id = new Guid(item["invoiceid"].ToString()),
                            LogicalName = "invoice",
                        },
                        State = new OptionSetValue(2),
                        Status = new OptionSetValue(100001),
                    };

                    _CrmService.Execute(request);

}

Monday, November 27, 2017

Loading IFrame on form - MS CRM Dynamics javascript

This is helpful to set the URL to IFRAME using javascript in MicroSoft Dynamics CRM.

use below script as reference to your javascript webresource.

you need to call the SetTransactionFrame() from onload even and save event of crm form.

// script to webpage to Iframe .. load web page on MS CRM form IFRAME.



var transactionsURL = "http:blogger.com";

function SetTransactionFrame()
{

 var subjectValue = Xrm.Page.getAttribute("subjectid").getValue();

 if ((subjectValue != null)) {
 
var subjectName = subjectValue[0].name;


var formType = Xrm.Page.ui.getFormType();
    if (formType !== 1 && subjectName=="yoursubject" )
        {
SetIFrameURL();
}
else
{
//"Details" - tab name
Xrm.Page.ui.tabs.get("Details").sections.get("Details_section_2").setVisible(false);
}

   }
}

function SetIFrameURL() {

    var CaseId = Xrm.Page.data.entity.getId();
    var UserId = Xrm.Page.context.getUserId();
   var FormType ="case";

    var transactionsURL = TransactionDetailsURL + '?id=' + CaseId +'&userid=' +UserId +'&typename='+FormType;


Xrm.Page.getControl('IFRAME_Transactions').setSrc(transactionsURL);
}