CRM operation View

Source: Internet
Author: User

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

/// <Summary>
/// View
/// </Summary>
Public class userqueryhelper
{
Public static readonly string entityname = "userquery ";
Public guid viewid = guid. empty;
Public iorganizationservice service;

/// <Summary>
/// Create a view
/// </Summary>
Public void create ()
{
# Region fetchxml
String fetchxml [email protected] "<fetch version = '1. 0' output-format = 'xml-platform 'ing ing = 'logical 'distinct = 'false'>
<Entity name = 'opportunit'>
<Order attribute = 'estimatedvalue' descending = 'false'/>
<Filter type = 'and'>
<Condition attribute = 'statecode' operator = 'eq'
Value = '0'/>
</Filter>
<Attribute name = 'name'/>
<Attribute name = 'estimatedvalue'/>
<Attribute name = 'estimatedclosedate'/>
<Attribute name = 'mermerid'/>
<Attribute name = 'opportunityratingcode'/>
<Attribute name = 'closeprobability '/>
<Link-entity alias = 'opportunitymermeridcontactcontactid'
Name = 'Contact 'from = 'contactid' to = 'mermerid'
Link-type = 'outer' visible = 'false'>
<Attribute name = 'emailssss1'/>
</Link-entity>
<Attribute name = 'opportunityid'/>
</Entity>
</Fetch> ";
# Endregion
# Region layoutxml
String layoutxml = @ "<grid name = 'result' object = '3' jump = 'name' select = '1' Preview = '1' icon = '1'>
<Row name = 'result' id = 'opportunityid'>
<Cell name = 'name' width = '000000'/>
<Cell name = 'mermerid' width = '000000'/>
<Cell name = 'estimatedclosedate' width = '000000'/>
<Cell name = 'estimatedvalue' width = '000000'/>
<Cell name = 'closeprobability 'width = '000000'/>
<Cell name = 'opportunityratingcode' width = '000000'/>
<Cell name = 'opportunitycustomeridcontactcontactid. emailaddress1'
Width = '000000' disablesorting = '1'/>
</Row>
</GRID> ";
# Endregion
Entity en = new entity () {logicalname = entityname };
En ["name"] = "Custom business opportunity View ";
En ["returnedtypecode"] = "opportunity ";
En ["querytype"] = 0;
En ["fetchxml"] = fetchxml;
En ["layoutxml"] = layoutxml;
En ["querytype"] = 0;
Viewid = service. Create (en );
}

/// <Summary>
/// Assign user query 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 = viewid };
Request. assignee = assignee;
Assignresponse response = (assignresponse) service. Execute (request );
}

/// <Summary>
/// Execute the previously saved query specified by the ID
/// </Summary>
Public void executebyiduserquery ()
{
Executebyiduserqueryrequest request = new executebyiduserqueryrequest ();
Request. entityid = new entityreference () {logicalname = entityname, id = viewid };
Executebyiduserqueryresponse response = (executebyiduserqueryresponse) service. Execute (request );
String result = response. String;
}

/// <Summary>
/// Delete all access permissions of the specified security subject (user or Team) for user query
/// </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 = viewid };
Request. revokee = revokee;
Revokeaccessresponse response = (revokeaccessresponse) service. Execute (request );
}

/// <Summary>
/// Delete View
/// </Summary>
Public void Delete ()
{
Service. Delete (entityname, viewid );
}

}

CRM operation View

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.