CRM operation sales order entity

Source: Internet
Author: User

Using system;
Using Microsoft. xrm. SDK;
Using Microsoft. xrm. SDK. query;
Using Microsoft. CRM. SDK. messages;

/// <Summary>
/// Sales order
/// </Summary>
Public class soleorderhelper
{
Public static readonly string entityname = "salesorder ";
Public guid soleorderid = guid. empty;
Public iorganizationservice service;

/// <Summary>
/// Create a sales order
/// </Summary>
Public void create (guid accountid)
{
Entity en = new entity () {logicalname = entityname, id = accountid };
En ["name"] = "sales order test ";
En ["accountid"] = new entityreference () {logicalname = "Account", id = accountid };
Soleorderid = service. Create (en );
}

/// <Summary>
/// Assign the sales order to another user or team
/// </Summary>
/// <Param name = "assignee"> User or team reference </param>
Public void assign (entityreference assignee)
{
Assignrequest request = new assignrequest ();
Request. Target = new entityreference () {logicalname = entityname, id = soleorderid };
Request. assignee = assignee;
Assignresponse response = (assignresponse) service. Execute (request );
}

/// <Summary>
/// Cancel the sales order
/// </Summary>
/// <Param name = "status"> canceled status </param>
Public void cancelsalesorder (INT status)
{
Cancelsalesorderrequest request = new cancelsalesorderrequest ();
Request. orderclose = new entity () {logicalname = entityname, id = soleorderid };
Request. Status = new optionsetvalue (Status );
Cancelsalesorderresponse response = (cancelsalesorderresponse) service. Execute (request );
}

/// <Summary>
/// Convert a sales order to an invoice
/// </Summary>
Public void convertsalesordertoinvoice ()
{
Convertsalesordertoinvoicerequest request = new convertsalesordertoinvoicerequest ();
Request. salesorderid = soleorderid;
Request. columnset = new columnset ("name", "accountid ");
Convertsalesordertoinvoiceresponse response = (convertsalesordertoinvoiceresponse) service. Execute (request );
Entity invoiceen = response. entity;
}

/// <Summary>
/// Complete the sales order
/// </Summary>
/// <Param name = "status"> completed status </param>
Public void fulfillsalesorder (INT status)
{
Fulfillsalesorderrequest request = new fulfillsalesorderrequest ();
Request. orderclose = new entity () {logicalname = entityname, id = soleorderid };
Request. Status = new optionsetvalue (Status );
Fulfillsalesorderresponse response = (fulfillsalesorderresponse) service. Execute (request );
}

/// <Summary>
/// Retrieve the product group of the sales order from the specified business opportunity
/// </Summary>
/// <Param name = "opportunityid"> business opportunity id </param>
Public void getsalesorderproductsfromopportunity (guid opportunityid)
{
Getsalesorderproductsfromopportunityrequest request = new getsalesorderproductsfromopportunityrequest ();
Request. opportunityid = opportunityid;
Request. salesorderid = soleorderid;
Getsalesorderproductsfromopportunityresponse response =
(Getsalesorderproductsfromopportunityresponse) service. Execute (request );
}

/// <Summary>
/// Lock sales order Pricing
/// </Summary>
Public void locksalesorderpricing ()
{
Locksalesorderpricingrequest request = new locksalesorderpricingrequest ();
Request. salesorderid = soleorderid;
Locksalesorderpricingresponse response = (locksalesorderpricingresponse) service. Execute (request );
}

/// <Summary>
/// Unlock the unit price of the product in the specified sales order (Order)
/// </Summary>
Public void unlocksalesorderpricing ()
{
Unlocksalesorderpricingrequest request = new unlocksalesorderpricingrequest ();
Request. salesorderid = soleorderid;
Unlocksalesorderpricingresponse response = (unlocksalesorderpricingresponse) service. Execute (request );
}

/// <Summary>
/// Cancel all access permissions of the specified security subject (user or Team) to the sales order
/// </Summary>
/// <Param name = "revokee"> User or team reference </param>
Public void revokeaccess (entityreference revokee)
{
Revokeaccessrequest request = new revokeaccessrequest ();
Request. Target = new entityreference () {logicalname = entityname, id = soleorderid };
Request. revokee = revokee;
Revokeaccessresponse response = (revokeaccessresponse) service. Execute (request );
}

/// <Summary>
/// Delete the sales order
/// </Summary>
Public void Delete ()
{
Service. Delete (entityname, soleorderid );
}
}

CRM operation sales order entity

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.