编程知识 cdmana.com

Dynamics CRM JavaScript operation

Dynamics CRM JavaScript Operation Daquan

One :js Assign a value to a field
1、 Single line text
Xrm.Page.getAttribute(‘Singlelinetext’).setValue(“ Single line text data ”);
2、 Integers
Xrm.Page.getAttribute(‘integer’).setValue(190 );
3、 Option set
Xrm.Page.getAttribute(‘OptionSet’).setValue(100000001);
4、 Two options
Xrm.Page.getAttribute(‘OptionSet’).setValue(true);
5、 Floating point numbers
Xrm.Page.getAttribute('new_Float ').setValue(10.2);
6、 Decimal number
Xrm.Page.getAttribute('new_Float ').setValue(104.1);
7、 currency
Xrm.Page.getAttribute('new_Float ').setValue(20000.1);
8、 Multiline text
Xrm.Page.getAttribute('new_Float ').setValue(“ The value of a multiline text field the value of a multiline text field the value of a multiline text field ---- The value of a multiline text field ”);
9、 Date and time
Xrm.Page.getAttribute('new_Float ').setValue(new date());
10、 lookup
attr(‘ The entity name ’).disable().setLookup(‘ The entity name ’, Find the value of an entity , Find entity's name)



















Two :c# Assign values to each type of field
1、 Single line text
RecordEntity[“new_lead”]=“ The value of a single line of text ”;
2、 Integers
RecordEntity[“new_lead”]=123;
3、 Option set
RecordEntity[“ The entity name ”]= new OptionSetValue(100000003);
4、 Two options
RecordEntity[“new_isornoappoint”] = true;
5、 Floating point numbers
RecordEntity[“float”] =10.1;
6、 Decimal number
RecordEntity[“decimalism”] =10.20;
7、 currency
RecordEntity[“new_ftmoney”] = new Money(90.0);
8、 Multiline text
RecordEntity[“new_ftmoney”] =“ The value of multiline text ”;
9、 Date and time
RecordEntity[“date”] =datetime.now;
10、 lookup
RecordEntity[“ The entity name ”]=new EntityReference(“ The name of the associated entity ”, Associated entities guid);;



















3、 ... and :Linq Inquire about
Single table
scene 1、OrganizationServiceContext orgServiceContext=new OrganizationService(service);

var result=from a in orgServiceContext.CreateQuery(“Account”) select a;
Ergodic set
foreach(var item in result)
{
xx=item[“attributename”];
}
scene 2、
var sql=from a in orgServiceContext.CreateQuery(“Account”)
Where a[“accounted”].Equals(xxxx)
Select new Account
{
AccountName=a[“accountName”],
Account_Address=a[“address”]
}
Ergodic set
Foreach(var item in sql)
{
xxx=item[“AccountName”];// When we take the value here, we use select Another name for
}
Multiple tables
var sql=from a in orgServiceContext.CreateQuery(“systemuser”)
join b in orgServiceContext.CreateQuery(“systemuserroles”)
on a.systemuserid equals b.systemuserid
join c in orgServiceContext.CreateQuery(“role”)
on b.roleid equals c.roles
where a[“name”].equals(“xxxx”)
Orderby a.name ascending
Select new
{
Name=a.name,
Role_Id=c.roleid
};
scene 3 : Paging large query result sets
int pageSize=5;
var accountByPage=from a in orgServiceContext.CreateQuery(“Account”)
select new Account
{
Name=a.name
};
Foreach






































Four 、fetchXml
Single table :
string fetch=@"<fetch version=’'1.0 outpu-format=‘xml-platform’ mapping=‘logical’ distinct=‘true’>

";
EntityCollection results=service.RetrieveMultiple(new FetchExpression(fetch));




Multiple tables :
string fetch=@"






<link_entity name=‘systemuserroles’ from=‘systemuserid’ to=‘systemuserid’ visable=‘false’ intersect=‘true’>
<link_entity name=‘role’ from =‘roleid’ to=‘roleid’ alias=‘aa’>







";
EntityCollection results=service.RetrieveMultiple(new FetchExpression(fetch));

















5、 ... and 、QueryBase
Single table :
QueryExpression query=new QueryExpression{
EntityName=“account”,
ColumnSet=new ColumnSet(true);
}




Multiple tables :
example :select a.ename,b.bname from emp a join dept b on a.deptno=b.deptno join customer c on b.customerid=c.customerid

QueryExpression query = new QueryExpression();
query.EntityName = “emp”;
query.ColumnSet = new ColumnSet();
query.ColumnSet.Columns.Add(“ename”);


        LinkEntity linkEntity = new LinkEntity("emp", "dept", "deptno", "deptno", JoinOperator.Inner);

        query.LinkEntities.Add(linkEntity); 
        query.LinkEntities[0].Columns.AddColumns("bname");
        query.LinkEntities[0].EntityAlias = "b";

LinkEntity linkEntity2 = new LinkEntity(“dept”, “customer”, “customerid”, “customerid”, JoinOperator.Inner);

        query.LinkEntities.Add(linkEntity2);
        query.LinkEntities[1].Columns.AddColumns("customername");
        query.LinkEntities[1].EntityAlias = "c";

        EntityCollection results = service.RetrieveMultiple(query);

        // Traversal result set 
foreach(Entity entity in results.Entities){
             string name=entity["ename"];  //from Table access directly 
 string bname=entity["b.bname"]; // I want to get it here dept The value of needs to be obtained by alias 
 string customername=entity["c.customername"]; // I want to get it here customer The value of needs to be obtained by alias 
}

版权声明
本文为[osc_ zg8wy3xa]所创,转载请带上原文链接,感谢
https://cdmana.com/2020/12/20201224095149212R.html

Scroll to Top