AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 07.09.2011, 17:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,644 / 848 (80) +++++++
Регистрация: 28.10.2006
Gareth Tucker: Launching CRM Forms via Java Script in CRM 2011
Источник: http://gtcrm.wordpress.com/2011/09/0...t-in-crm-2011/
==============

Here’s a couple of examples demonstrating how to pop CRM forms via java script (from a CRM form event / ribbon button).

This first example shows how to pop an existing record, in this case a Case record.  In this scenario I have a field called Existing Case (new_existingcase) on the Phone Call form which is a lookup field to the Case entity.   This function reads the GUID and name value of that Case and then pops that record using a window.open command:


function PopCase() { //Get the value of the ExistingCase field var ExistingCase = Xrm.Page.data.entity.attributes.get("new_existingcase"); if (ExistingCase.getValue() != null) { //Split out the GUID and Name from the ExistingCase field var ExistingCaseGUID = ExistingCase.getValue()[0].id; var ExistingCaseName = ExistingCase.getValue()[0].name; //Set features for how the Case form window will appear var features = "location=no,menubar=no,status=no,toolbar=no"; //Pop the Case record window.open("/main.aspx?etn=incident&pagetype=entityrecord&id=" + encodeURIComponent(ExistingCaseGUID), "_blank", features, false); } }
 

This second example shows how to create a new record, again let’s look at the Case entity.  In this scenario my code sits on the Phone Call form and want to create a new Case for the Customer specified on the Phone Call.  First I retrieve the details of the Customer from the CRM form (from the “from” field).  Then in a variable called extraqs I define the parameter values I want to pass across to the form so that some of the field values default, including the Customer field.   Note that to populate a Customer lookup field I have to provide 3 parameter values (for simpler lookup fields you supply just the first 2 values).  Then, to pop the form, it’s a simple window.open with the parameters variable included:

//Collect values from the existing CRM form that you want to default onto your new record var CallerGUID = Xrm.Page.data.entity.attributes.get("from").getValue()[0].id; var CallerName = Xrm.Page.data.entity.attributes.get("from").getValue()[0].name; //Set the parameter values var extraqs = "&title=New Case"; extraqs += "&customerid=" + CallerGUID; extraqs += "&customeridname=" + CallerName; extraqs += "&customeridtype=contact"; //Set features for how the window will appear var features = "location=no,menubar=no,status=no,toolbar=no"; //Pop the window window.open("/main.aspx?etn=incident&pagetype=entityrecord&extraqs=" + encodeURIComponent(extraqs), "_blank", features, false);
 

Hope this is helpful.




Источник: http://gtcrm.wordpress.com/2011/09/0...t-in-crm-2011/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Gareth Tucker: Installing the Customer Care Accelerator (CCA) for CRM 2011 Blog bot Dynamics CRM: Blogs 3 23.12.2011 09:16
Gareth Tucker: Editing Ribbon Buttons in CRM 2011 Blog bot Dynamics CRM: Blogs 0 24.08.2011 09:11
Microsoft Dynamics CRM Team Blog: Microsoft Dynamics CRM 2011 ~ Online Test Drive Guide Blog bot Dynamics CRM: Blogs 0 05.08.2011 20:13
Gareth Tucker: CRM 2011 Command Line Installs – continued… Blog bot Dynamics CRM: Blogs 0 25.07.2011 10:11
Gareth Tucker: Getting Started with CRM 2011 Online Fetch XML Reporting Blog bot Dynamics CRM: Blogs 0 19.05.2011 23:13

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 16:23.