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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 23.09.2013, 11:30   #1  
Ion is offline
Ion
Участник
 
332 / 16 (1) ++
Регистрация: 19.12.2012
SetParameter не работает?
Добрый день, коллеги!

Есть задача: фильтровать записи в SubGrid в зависимости от значения поля с типом набор параметров.

Проблема на финальной стадии, когда я пытаюсь установить setParameter мне выдает что объект не поддерживает свойство или метод или не удалось получить свойство "SetParameter" ссылки, значение которой не определено или является NULL.

Вот сам код:

Цитата:

function filterSubGrid() {

//var accountsGrid = document.getElementById("new_dogovorGrid"); //grid to filter

var Casko = 100000001;
var Osago = 100000000;
var reguestGrid =Xrm.Page.ui.controls.get('new_dogovorGrid')._control;
debugger;
if (reguestGrid == null) { //make sure the grid has loaded
setTimeout(function () { updateSubGrid(); }, 2000); //if the grid hasn’t loaded run this again when it has
return;
}

var accountValue = Xrm.Page.getAttribute("new_account").getValue(); //field to filter by
var ProductValue = Xrm.Page.getAttribute("new_insurance_product").getValue(); //field to filter by

var accountId = "00000000-0000-0000-0000-000000000000"; //if filter field is null display nothing

if (accountValue != null && (ProductValue == Casko || ProductValue == Osago)) {
var accountId = accountValue[0].id;
}

//fetch xml code which will retrieve all the accounts related to the contact
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
" <entity name='new_request'>" +
" <attribute name='new_requestid' />" +
" <attribute name='new_insurance_product' />" +
" <attribute name='new_insuransepayment' />" +
" <attribute name='new_total_limit' />" +
" <attribute name='new_client_account' />" +
" <order attribute='new_insurance_product' descending='false' />" +
" <filter type='and'>" +
" <condition attribute='new_client_account' operator='eq' uitype='account' value='" + accountId + "' />" +
" <condition attribute='new_insurance_product' operator='eq' value='" + ProductValue + "'/>" +
" <condition attribute='new_stage' operator='eq' value='100000006' />" +
" <condition attribute='new_result' operator='eq' value='1' /> " +
" </filter>" +
" </entity>" +
"</fetch>";


если пишу так - то объект не поддерживает свойство или метод
reguestGrid.setParameter("fetchXml", fetchXml); -

reguestGrid.refresh(); //refresh the sub grid using the new fetch xml


если пишу так - то не удалось получить свойство "SetParameter" ссылки, значение которой не определено или является NULL.

// reguestGrid.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid

// reguestGrid.control.refresh(); //refresh the sub grid using the new fetch xml
}
Старый 23.09.2013, 17:43   #2  
spectr is offline
spectr
Участник
Аватар для spectr
MCBMSS
Лучший по профессии 2014
 
287 / 70 (3) ++++
Регистрация: 19.10.2011
Адрес: Киев
поле UR12 они переименовали метод с SetParameter на setParameter или на оборот точно не помню.
Но нужно писать точно reguestGrid.control.setParameter
А для поддержки нескольких ролапов нужно писать так:
Код:
if (typeof  reguestGrid.control.setParameter != "undefined"){
 reguestGrid.control.setParameter("fetchXml", fetchXml);
}
if (typeof  reguestGrid.control.SetParameter != "undefined"){
 reguestGrid.control.SetParameter("fetchXml", fetchXml);
}
Старый 23.09.2013, 21:22   #3  
Ion is offline
Ion
Участник
 
332 / 16 (1) ++
Регистрация: 19.12.2012
Этот код не работает, ошибка осталась. Я сети я находил подобный код.
Переименовалась с setParameter на setParameter.

Может еще кто-то подкинет идеи?

Цитата:
Сообщение от spectr Посмотреть сообщение
поле UR12 они переименовали метод с сна setParameter или на оборот точно не помню.
Но нужно писать точно reguestGrid.control.setParameter
А для поддержки нескольких ролапов нужно писать так:
Код:
if (typeof  reguestGrid.control.setParameter != "undefined"){
 reguestGrid.control.setParameter("fetchXml", fetchXml);
}
if (typeof  reguestGrid.control.SetParameter != "undefined"){
 reguestGrid.control.SetParameter("fetchXml", fetchXml);
}
Старый 23.09.2013, 22:21   #4  
Konstantin Katsovich is offline
Konstantin Katsovich
Участник
Аватар для Konstantin Katsovich
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
 
243 / 57 (2) ++++
Регистрация: 22.10.2008
Адрес: Israel
У меня вот такой код работает на 12,13 ролапе
Код:
var Interval = null;

function OnLoadForm() {
    var fetchXml = 'YOUR FETCH';
    ChangeFetch("YOUR SUBGRID NAME", fetchXml);
}

function ChangeFetch(sGridName, fetchXML) {
    Init();
    function Init() {
        Interval = setInterval(function () {
            var grid = document.getElementById(sGridName);
            if (grid != null && typeof grid.control != 'undefined' && grid.control != null) {
                clearInterval(Interval);
                try {
                    grid.control.SetParameter("fetchXml", fetchXML);
                    grid.control.refresh();
                }
                catch (e) { }
            }
        }, 300);
    }
}
У вас сабгрид на форме где находится в табе? секции? в открытом? закрытом?
Он первый на форме?
__________________
Читайте SDK!!!
Старый 24.09.2013, 11:23   #5  
spectr is offline
spectr
Участник
Аватар для spectr
MCBMSS
Лучший по профессии 2014
 
287 / 70 (3) ++++
Регистрация: 19.10.2011
Адрес: Киев
Цитата:
Этот код не работает, ошибка осталась. Я сети я находил подобный код.
потому что вы использовать такое:
Цитата:
var reguestGrid =Xrm.Page.ui.controls.get('new_dogovorGrid')._control;
А нужно:
Код:
var reguestGrid = document.getElementById("new_dogovorGrid");
....
if (typeof  reguestGrid.control.setParameter != "undefined"){
 reguestGrid.control.setParameter("fetchXml", fetchXml);
}
if (typeof  reguestGrid.control.SetParameter != "undefined"){
 reguestGrid.control.SetParameter("fetchXml", fetchXml);
}
И проверка на готовность грида не коректна
Вместо:
Цитата:
if (reguestGrid == null) { //make sure the grid has loaded
setTimeout(function () { updateSubGrid(); }, 2000); //if the grid hasn’t loaded run this again when it has
return;
}
Нужно: (примитив)
Код:
if (reguestGrid != null)
	{
		if (reguestGrid .readyState != "complete")
		{
			setTimeout(updateSubGrid, 1000);
			return;
		}
	}
	else
	{
		setTimeout(updateSubGrid, 1000);
		return;
	}
или как у Konstantin Katsovich:
Код:
if (grid != null && typeof grid.control != 'undefined' && grid.control != null)

Последний раз редактировалось spectr; 24.09.2013 в 11:30.
Старый 24.09.2013, 18:35   #6  
Ion is offline
Ion
Участник
 
332 / 16 (1) ++
Регистрация: 19.12.2012
Я код переписал, мне не ясно почему если пишу так, то переменная содержит значение reguestGrid {...} Object, (FormUIControl)


Цитата:
var reguestGrid =Xrm.Page.ui.controls.get('new_dogovorGrid')._control;


А переменная reguestGrid = undefined, когда пишу таким образом document.getElementById("new_dogovorGrid") = [Object, HTMLDivElement]

Цитата:
var reguestGrid = document.getElementById("new_dogovorGrid")


Цитата:

function filterSubGrid() {


var Casko = 100000001;
var Osago = 100000000;

var reguestGrid =Xrm.Page.ui.controls.get('new_dogovorGrid')._control;

var reguestGrid1 = document.getElementById("new_dogovorGrid");

debugger;

if (reguestGrid != null)
{
if (reguestGrid .readyState != "complete")
{
setTimeout(filterSubGrid, 1000);
return;
}
}
else
{
setTimeout(filterSubGrid, 1000);
return;
}

var accountValue = Xrm.Page.getAttribute("new_account").getValue(); //field to filter by
var ProductValue = Xrm.Page.getAttribute("new_insurance_product").getValue(); //field to filter by

var accountId = "00000000-0000-0000-0000-000000000000"; //if filter field is null display nothing

if (accountValue != null && (ProductValue == Casko || ProductValue == Osago)) {
var accountId = accountValue[0].id;
}

//fetch xml code which will retrieve all the accounts related to the contact
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
" <entity name='new_request'>" +
" <attribute name='new_requestid' />" +
" <attribute name='new_insurance_product' />" +
" <attribute name='new_insuransepayment' />" +
" <attribute name='new_total_limit' />" +
" <attribute name='new_client_account' />" +
" <order attribute='new_insurance_product' descending='false' />" +
" <filter type='and'>" +
" <condition attribute='new_client_account' operator='eq' uitype='account' value='" + accountId + "' />" +
" <condition attribute='new_insurance_product' operator='eq' value='" + ProductValue + "'/>" +
" <condition attribute='new_stage' operator='eq' value='100000006' />" +
" <condition attribute='new_result' operator='eq' value='1' /> " +
" </filter>" +
" </entity>" +
"</fetch>";

if (typeof reguestGrid.control.setParameter != "undefined"){
reguestGrid.control.setParameter("fetchXml", fetchXml);
}

if (typeof reguestGrid.control.SetParameter != "undefined"){
reguestGrid.control.SetParameter("fetchXml", fetchXml);

}

}
Старый 24.09.2013, 18:41   #7  
Ion is offline
Ion
Участник
 
332 / 16 (1) ++
Регистрация: 19.12.2012
Грид находится в отдельной вкладке, в разделе, и открыт постоянно, на форме он последний

Последний раз редактировалось Ion; 24.09.2013 в 18:55.
Старый 25.09.2013, 00:59   #8  
a33ik is offline
a33ik
Чайный пьяница
Аватар для a33ik
MCP
MCBMSS
Злыдни
Соотечественники
Most Valuable Professional
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
Лучший по профессии 2011
Лучший по профессии 2009
 
3,243 / 896 (36) +++++++
Регистрация: 02.07.2008
Адрес: Greenville, SC
Добрый день,

Посмотрите - http://www.magnetismsolutions.com/bl...-%28polaris%29
__________________
Эмо разработчик, сначала пишу код, потом плачу над его несовершенством.

Подписывайтесь на мой блог, twitter и YouTube канал.
Пользуйтесь моим Ultimate Workflow Toolkit
Старый 25.09.2013, 18:54   #9  
Ion is offline
Ion
Участник
 
332 / 16 (1) ++
Регистрация: 19.12.2012
Сделал как в примере, СРМ выводит сообщение: Недопустимый XML формат.
Цитата:
Сообщение от a33ik Посмотреть сообщение
Вот лог ошибки, что к чему не ясно мне пока.

Цитата:
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.Xml.XmlException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #044F499ADetail:
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
<ErrorCode>-2147220970</ErrorCode>
<ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
<KeyValuePairOfstringanyType>
<d2p1:key>CallStack</d2p1:key>
<d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string"> в Microsoft.Crm.Application.WebServices.AppGridWebServiceHandler.ProcessRequestInternal(HttpContext context)
в System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
в System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)</d2p1:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>
<Message>System.Xml.XmlException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #044F499A</Message>
<Timestamp>2013-09-25T14:46:35.5114095Z</Timestamp>
<InnerFault>
<ErrorCode>-2147220991</ErrorCode>
<ErrorDetails xmlns:d3p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
<KeyValuePairOfstringanyType>
<d3p1:key>CallStack</d3p1:key>
<d3p1:value xmlns:d5p1="http://www.w3.org/2001/XMLSchema" i:type="d5p1:string"> в Microsoft.Crm.Query.EntityExpression.InternalDeserializeFromFetchXml(String xmlInfo, ParsingConditionValuesOption parsingOption)
в Microsoft.Crm.Application.Platform.Grid.GridDataProviderQueryBuilder.SetupQueryBuilder(QueryBuilder queryBuilder, View view)
в Microsoft.Crm.Application.Platform.Grid.GridDataProviderQueryBuilder.LoadQueryData()
в Microsoft.Crm.Application.Platform.Grid.GridDataProviderQueryBuilder.LoadData()
в Microsoft.Crm.Application.Platform.Grid.GridDataProviderBase.PrepareGridData()
в Microsoft.Crm.Application.Platform.Grid.GridDataProviderBase.PrepareData()
в Microsoft.Crm.Application.Controls.GridUIProvider.Render(HtmlTextWriter output)
в Microsoft.Crm.Application.WebServices.AppGridWebServiceHandler.GetRefreshResponseHtml(IGridUIProvider uiProvider, StringBuilder sbTemp)
в Microsoft.Crm.Application.WebServices.AppGridWebServiceHandler.Refresh(String gridXml, StringBuilder sbXml, StringBuilder sbHtml, Boolean returnJsonData)
в Microsoft.Crm.Application.WebServices.AppGridWebServiceHandler.ProcessRequestInternal(HttpContext context)</d3p1:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>
<Message>Invalid XML.</Message>
<Timestamp>2013-09-25T14:46:35.5114095Z</Timestamp>
<InnerFault>
<ErrorCode>-2147220970</ErrorCode>
<ErrorDetails xmlns:d4p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
<KeyValuePairOfstringanyType>
<d4p1:key>CallStack</d4p1:key>
<d4p1:value xmlns:d6p1="http://www.w3.org/2001/XMLSchema" i:type="d6p1:string"> в System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
в System.Xml.XmlTextReaderImpl.ThrowTagMismatch(NodeData startTag)
в System.Xml.XmlTextReaderImpl.ParseEndElement()
в System.Xml.XmlTextReaderImpl.ParseElementContent()
в System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
в System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
в System.Xml.XmlDocument.Load(XmlReader reader)
в Microsoft.Crm.Query.XmlDomHelper.LoadXmlInfo(String xmlInfo)
в Microsoft.Crm.Query.EntityExpression.InternalDeserializeFromFetchXml(String xmlInfo, ParsingConditionValuesOption parsingOption)</d4p1:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>
<Message>System.Xml.XmlException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #5B878BDA</Message>
<Timestamp>2013-09-25T14:46:35.5114095Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText i:nil="true" />
</InnerFault>
<TraceText i:nil="true" />
</InnerFault>
<TraceText i:nil="true" />
</OrganizationServiceFault>


Старый 25.09.2013, 19:42   #10  
a33ik is offline
a33ik
Чайный пьяница
Аватар для a33ik
MCP
MCBMSS
Злыдни
Соотечественники
Most Valuable Professional
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
Лучший по профессии 2011
Лучший по профессии 2009
 
3,243 / 896 (36) +++++++
Регистрация: 02.07.2008
Адрес: Greenville, SC
Можете после

Код:
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
" <entity name='new_request'>" +
" <attribute name='new_requestid' />" +
" <attribute name='new_insurance_product' />" +
" <attribute name='new_insuransepayment' />" +
" <attribute name='new_total_limit' />" +
" <attribute name='new_client_account' />" +
" <order attribute='new_insurance_product' descending='false' />" +
" <filter type='and'>" +
" <condition attribute='new_client_account' operator='eq' uitype='account' value='" + accountId + "' />" +
" <condition attribute='new_insurance_product' operator='eq' value='" + ProductValue + "'/>" +
" <condition attribute='new_stage' operator='eq' value='100000006' />" +
" <condition attribute='new_result' operator='eq' value='1' /> " +
" </filter>" +
" </entity>" +
"</fetch>";
вставить alert, который покажет фильтр?

В ProductValue - текстовое значение? Точно не лукап?
__________________
Эмо разработчик, сначала пишу код, потом плачу над его несовершенством.

Подписывайтесь на мой блог, twitter и YouTube канал.
Пользуйтесь моим Ultimate Workflow Toolkit
Старый 25.09.2013, 21:13   #11  
Ion is offline
Ion
Участник
 
332 / 16 (1) ++
Регистрация: 19.12.2012
Цитата:
вставить alert, который покажет фильтр?
Вот он:

Цитата:
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='new_request'>
<attribute name='new_requestid' />
<attribute name='new_insuransepayment' />
<attribute name='new_total_limit' />
<attribute name='new_client_account' />
<attribute name='new_insurance_product' />
<order attribute='new_insurance_product' descending='false' />
<filter type='and'>
<condition attribute='new_client_account' operator='eq' uitype='account' value='{BAF1A4C8-3C03-E311-8620-00155D001525}' />
<condition attribute='new_insurance_product' operator='eq' value='100000000'/>
<condition attribute='new_stage' operator='eq' value='100000006' />
<condition attribute='new_result' operator='eq' value='1' />
</filter>
</link-entity>
</entity>
</fetch>

Вроде все корректно. Непонятно.


Цитата:
В ProductValue - текстовое значение? Точно не лукап?
Нет, там тип OptionSet.
Старый 25.09.2013, 21:46   #12  
Ion is offline
Ion
Участник
 
332 / 16 (1) ++
Регистрация: 19.12.2012
Разобрался, всем спасибо)
Старый 25.09.2013, 22:37   #13  
a33ik is offline
a33ik
Чайный пьяница
Аватар для a33ik
MCP
MCBMSS
Злыдни
Соотечественники
Most Valuable Professional
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
Лучший по профессии 2011
Лучший по профессии 2009
 
3,243 / 896 (36) +++++++
Регистрация: 02.07.2008
Адрес: Greenville, SC
Цитата:
Сообщение от Ion Посмотреть сообщение
Разобрался, всем спасибо)
А поделиться?
__________________
Эмо разработчик, сначала пишу код, потом плачу над его несовершенством.

Подписывайтесь на мой блог, twitter и YouTube канал.
Пользуйтесь моим Ultimate Workflow Toolkit
Старый 26.09.2013, 00:04   #14  
Ion is offline
Ion
Участник
 
332 / 16 (1) ++
Регистрация: 19.12.2012
Цитата:
Сообщение от a33ik Посмотреть сообщение
А поделиться?

Да тут все настолько просто, что мне аж стыдно. Правил XML-ку, и вместо </entity>, оставил </link-entity>, вот эта ошибка и вызывает такое сообщение.
Старый 26.09.2013, 00:06   #15  
Ion is offline
Ion
Участник
 
332 / 16 (1) ++
Регистрация: 19.12.2012
Цитата:
Сообщение от a33ik Посмотреть сообщение
Надо делать по этому примеру. Реально выручило.

Спасибо a33ik
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Не работает простой отчет. Dzam Dynamics CRM: Разработка 4 20.10.2015 11:46
axforum blogs: Правила поиска дубликатов (Duplicate Detection Rules) CRM 2011. Как это работает и почему правила иногда автоматически становятся черновиками? Blog bot Dynamics CRM: Blogs 0 11.03.2013 20:11
Не работает фильтрация по сроку в действиях DimaV Dynamics CRM: Функционал 9 29.04.2010 06:48
CRM Deployment Manager. User manager не работает kras Dynamics CRM: Администрирование 18 05.12.2006 17:34
CRM очень медленно работает... CRM30 Dynamics CRM: Администрирование 12 26.07.2006 18:01

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

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

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 10:36.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.