MSCRM 调用lookup js
1 //函数放在Globle.js
2
3
4
5 多选:/mscrm/_controls/lookup/lookupmulti.aspx?class=ActivityRecipient&objecttypes=1,2,4,8,2020&browse=0&ShowNewButton=1&ShowPropButton=1&DefaultType=0
6
7 单选:/mscrm/_controls/lookup/lookupsingle.aspx?class=ActivitySenderAsAnotherUser&objecttypes=8,2020&browse=0&ShowNewButton=1&ShowPropButton=1&DefaultType=0
8
9
10
11
12
13 function AddLookup(lookupfield, otype,otypename,lookuptypeIcon,lookupclass)
14
15 {
16
17 var sId = lookupfield.DataValue;
18
19 var sName = "";
20
21 if(typeof(sId) != "undefined" && sId != null && sId != "")
22
23 {
24
25 //var sUrl = "/MsCrmExtension/GetAccountName.aspx?id="+sId.toString();
26
27 //sName = GetUrlResponse(sUrl);
28
29 sName = lookupfield.DataValue[0].name;
30
31 }
32
33 else
34
35 {
36
37 sId= "";
38
39 }
40
41
42
43 var sTemp = "id=\"" + lookupfield.id + "\"";
44
45 sTemp += " lookuptypenames=\"" + otypename + ":" + otype + "\"";
46
47 sTemp += " lookuptypeIcons=\"" + lookuptypeIcon + "\"";
48
49
50
51 var sLookupTbl = "<table class=\"ms-crm-Lookup\" cellpadding=\"0\" width=\"100%\" style=\"TABLE-LAYOUT:fixed\">";
52
53 sLookupTbl += "<tr>";
54
55 sLookupTbl += "<td><div ime-mode=\"auto\" class=\"ms-crm-Lookup\" tabindex=\"1061000\"></div>";
56
57 sLookupTbl += "<label class=\"ms-crm-Hidden-NoBehavior\" for=\"" + lookupfield.id + "_ledit\"></label>";
58
59 sLookupTbl += "<input class=\"ms-crm-Hidden-NoBehavior\" ime-mode=\"auto\" type=\"text\" tabindex="1060000"";
60
61 sLookupTbl += "id=\"l" + lookupfield.id + "_ledit\" maxlength=\"1000\"></td>"; typeofsLookupTbl += "<td width=\"25px;\" CLASS=\"Lookup_RenderButton_td\">";
62
63 sLookupTbl += "<img src=\"/_imgs/btn_off_lookup.gif\" class=\"ms-crm-Lookup\" ";
64
65 sLookupTbl += sTemp;
66
67 sLookupTbl += "lookupbrowse=\"0\" lookupstyle=\"single\" defaulttype=\"0\" req=\"0\" autoresolve=\"1\" showproperty=\"1\" sLookupTbl += "resolveemailaddress=\"0\" Style=\"ime-mode:auto\">";
68
69 sLookupTbl += "<a href=\"#\" onclick=\"previousSibling.click();\" tabindex=\"-1\">;
70
71 sLookupTbl += "></a></td></tr></table>";
72
73
74
75 lookupfield.style.display = "none";
76
77 lookupfield.parentElement.innerHTML = sLookupTbl;
78
79
80
81 }
82
83
84
85 <script type="text/JavaScript">
86
87 alimama_pid="mm_10879058_903490_1854743";
88
89 alimama_titlecolor="0000FF";
90
91 alimama_descolor ="000000";
92
93 alimama_bgcolor="FFFFFF";
94
95 alimama_bordercolor="E6E6E6";
96
97 alimama_linkcolor="008000";
98
99 alimama_bottomcolor="FFFFFF";
100
101 alimama_anglesize="0";
102
103 alimama_bgpic="0";
104
105 alimama_icon="0";
106
107 alimama_sizecode="11";
108
109 alimama_width=760;
110
111 alimama_height=90;
112
113 alimama_type=2;
114
115 </script>
116
117 <script src="http://a.alimama.cn/inf.js" type=text/javascript>
118
119 </script>
120
121 // 这个是放在Onload里面调用
122
123 //oendcustomername指定的字段 crmForm.all.字段名
124
125 //“1”:实体ID
126
127 //“account”:实体
128
129 AddLookup(oEndCustomerName, "1", "account", "/_imgs/ico_16_1.gif", "BasicCustomer", "false");
130
131
132
133 var strLl_dlsId="500c9140-e0f3-dc11-8a4c-0003ffadfcd8";
134
135 var xml = "" + "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
136
137 "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
138
139 " <soap:Body>" +
140
141 " <query xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryExpression\" xmlns=\"http://schemas.microsoft.com/crm/2006/WebServices\">" +
142
143 " <q1:EntityName>ll_dls</q1:EntityName>" +
144
145 " <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" +
146
147 " <q1:Attributes>" +
148
149 " <q1:Attribute>ll_dlsid</q1:Attribute>" +
150
151 " <q1:Attribute>ll_xm</q1:Attribute>" +
152
153 " </q1:Attributes>" +
154
155 " </q1:ColumnSet>" +
156
157 " <q1:Distinct>false</q1:Distinct>" +
158
159 " <q1:Criteria>" +
160
161 " <q1:FilterOperator>And</q1:FilterOperator>" +
162
163 " <q1:Conditions>" +
164
165 " <q1:Condition>" +
166
167 " <q1:AttributeName>ll_dlsid</q1:AttributeName>" +
168
169 " <q1:Operator>Equal</q1:Operator>" +
170
171 " <q1:Values>" +
172
173 " <q1:Value xmlns:q2=\"http://microsoft.com/wsdl/types/\""+
174
175 " xsi:type=\"q2:guid\">" +
176
177 strLl_dlsId+
178
179 " </q1:Value>" +
180
181 " </q1:Values>" +
182
183 " </q1:Condition>" +
184
185 " </q1:Conditions>" +
186
187 " </q1:Criteria>" +
188
189 " </query>" +
190
191 " </soap:Body>" +
192
193 "</soap:Envelope>" +"";
194
195
196
197 var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
198
199
200
201 xmlHttpRequest.Open("POST", "/mscrmservices/2006/CrmService.asmx", false);
202
203 xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2006/WebServices/RetrieveMultiple");
204
205 xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
206
207 xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
208
209 xmlHttpRequest.send(xml);
210
211
212
213 var doc = xmlHttpRequest.responseXML;
214
215 var user = doc.selectSingleNode("//BusinessEntity");
216
217
218
219 var dlsid = user.selectSingleNode("ll_dlsid").text;
220
221 alert(dlsid);
222
223
224
225 var ll_xm = user.selectSingleNode("ll_xm").text;
226
227 alert(ll_xm);
请参看:http://www.igooya.cn/bbs/viewthread.php?tid=220&extra=page%3D1
2
3
4
5 多选:/mscrm/_controls/lookup/lookupmulti.aspx?class=ActivityRecipient&objecttypes=1,2,4,8,2020&browse=0&ShowNewButton=1&ShowPropButton=1&DefaultType=0
6
7 单选:/mscrm/_controls/lookup/lookupsingle.aspx?class=ActivitySenderAsAnotherUser&objecttypes=8,2020&browse=0&ShowNewButton=1&ShowPropButton=1&DefaultType=0
8
9
10
11
12
13 function AddLookup(lookupfield, otype,otypename,lookuptypeIcon,lookupclass)
14
15 {
16
17 var sId = lookupfield.DataValue;
18
19 var sName = "";
20
21 if(typeof(sId) != "undefined" && sId != null && sId != "")
22
23 {
24
25 //var sUrl = "/MsCrmExtension/GetAccountName.aspx?id="+sId.toString();
26
27 //sName = GetUrlResponse(sUrl);
28
29 sName = lookupfield.DataValue[0].name;
30
31 }
32
33 else
34
35 {
36
37 sId= "";
38
39 }
40
41
42
43 var sTemp = "id=\"" + lookupfield.id + "\"";
44
45 sTemp += " lookuptypenames=\"" + otypename + ":" + otype + "\"";
46
47 sTemp += " lookuptypeIcons=\"" + lookuptypeIcon + "\"";
48
49
50
51 var sLookupTbl = "<table class=\"ms-crm-Lookup\" cellpadding=\"0\" width=\"100%\" style=\"TABLE-LAYOUT:fixed\">";
52
53 sLookupTbl += "<tr>";
54
55 sLookupTbl += "<td><div ime-mode=\"auto\" class=\"ms-crm-Lookup\" tabindex=\"1061000\"></div>";
56
57 sLookupTbl += "<label class=\"ms-crm-Hidden-NoBehavior\" for=\"" + lookupfield.id + "_ledit\"></label>";
58
59 sLookupTbl += "<input class=\"ms-crm-Hidden-NoBehavior\" ime-mode=\"auto\" type=\"text\" tabindex="1060000"";
60
61 sLookupTbl += "id=\"l" + lookupfield.id + "_ledit\" maxlength=\"1000\"></td>"; typeofsLookupTbl += "<td width=\"25px;\" CLASS=\"Lookup_RenderButton_td\">";
62
63 sLookupTbl += "<img src=\"/_imgs/btn_off_lookup.gif\" class=\"ms-crm-Lookup\" ";
64
65 sLookupTbl += sTemp;
66
67 sLookupTbl += "lookupbrowse=\"0\" lookupstyle=\"single\" defaulttype=\"0\" req=\"0\" autoresolve=\"1\" showproperty=\"1\" sLookupTbl += "resolveemailaddress=\"0\" Style=\"ime-mode:auto\">";
68
69 sLookupTbl += "<a href=\"#\" onclick=\"previousSibling.click();\" tabindex=\"-1\">;
70
71 sLookupTbl += "></a></td></tr></table>";
72
73
74
75 lookupfield.style.display = "none";
76
77 lookupfield.parentElement.innerHTML = sLookupTbl;
78
79
80
81 }
82
83
84
85 <script type="text/JavaScript">
86
87 alimama_pid="mm_10879058_903490_1854743";
88
89 alimama_titlecolor="0000FF";
90
91 alimama_descolor ="000000";
92
93 alimama_bgcolor="FFFFFF";
94
95 alimama_bordercolor="E6E6E6";
96
97 alimama_linkcolor="008000";
98
99 alimama_bottomcolor="FFFFFF";
100
101 alimama_anglesize="0";
102
103 alimama_bgpic="0";
104
105 alimama_icon="0";
106
107 alimama_sizecode="11";
108
109 alimama_width=760;
110
111 alimama_height=90;
112
113 alimama_type=2;
114
115 </script>
116
117 <script src="http://a.alimama.cn/inf.js" type=text/javascript>
118
119 </script>
120
121 // 这个是放在Onload里面调用
122
123 //oendcustomername指定的字段 crmForm.all.字段名
124
125 //“1”:实体ID
126
127 //“account”:实体
128
129 AddLookup(oEndCustomerName, "1", "account", "/_imgs/ico_16_1.gif", "BasicCustomer", "false");
130
131
132
133 var strLl_dlsId="500c9140-e0f3-dc11-8a4c-0003ffadfcd8";
134
135 var xml = "" + "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
136
137 "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
138
139 " <soap:Body>" +
140
141 " <query xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryExpression\" xmlns=\"http://schemas.microsoft.com/crm/2006/WebServices\">" +
142
143 " <q1:EntityName>ll_dls</q1:EntityName>" +
144
145 " <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" +
146
147 " <q1:Attributes>" +
148
149 " <q1:Attribute>ll_dlsid</q1:Attribute>" +
150
151 " <q1:Attribute>ll_xm</q1:Attribute>" +
152
153 " </q1:Attributes>" +
154
155 " </q1:ColumnSet>" +
156
157 " <q1:Distinct>false</q1:Distinct>" +
158
159 " <q1:Criteria>" +
160
161 " <q1:FilterOperator>And</q1:FilterOperator>" +
162
163 " <q1:Conditions>" +
164
165 " <q1:Condition>" +
166
167 " <q1:AttributeName>ll_dlsid</q1:AttributeName>" +
168
169 " <q1:Operator>Equal</q1:Operator>" +
170
171 " <q1:Values>" +
172
173 " <q1:Value xmlns:q2=\"http://microsoft.com/wsdl/types/\""+
174
175 " xsi:type=\"q2:guid\">" +
176
177 strLl_dlsId+
178
179 " </q1:Value>" +
180
181 " </q1:Values>" +
182
183 " </q1:Condition>" +
184
185 " </q1:Conditions>" +
186
187 " </q1:Criteria>" +
188
189 " </query>" +
190
191 " </soap:Body>" +
192
193 "</soap:Envelope>" +"";
194
195
196
197 var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
198
199
200
201 xmlHttpRequest.Open("POST", "/mscrmservices/2006/CrmService.asmx", false);
202
203 xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2006/WebServices/RetrieveMultiple");
204
205 xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
206
207 xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
208
209 xmlHttpRequest.send(xml);
210
211
212
213 var doc = xmlHttpRequest.responseXML;
214
215 var user = doc.selectSingleNode("//BusinessEntity");
216
217
218
219 var dlsid = user.selectSingleNode("ll_dlsid").text;
220
221 alert(dlsid);
222
223
224
225 var ll_xm = user.selectSingleNode("ll_xm").text;
226
227 alert(ll_xm);