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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 22.09.2011, 14:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,448 / 846 (79) +++++++
Регистрация: 28.10.2006
emeadaxsupport: Microsoft Dynamincs AX 2009 Workflow: Notification message does not contain PO number
Источник: http://blogs.msdn.com/b/emeadaxsuppo...po-number.aspx
==============

We recently came across problem with Workflow notification message. We have set up template workflow for process Purchase requisition approval (PurchReqApproval). When purchase requisition gets approved the process should create automatically Purchase Order (setting parameter “Auto create purchase order” in Accounts payable > Setup > Parameters on tab Purchase requisition). For even Completed we set up following notification:

“Purchase requisition order: %Purchase Requisition.PurchReqId% has been approved and new purchase order was created with number: %Purchase Requisition.Purchase requisition lines.PurchId%”.

After workflow has finished correctly the notification was sent. The problem is that notification looks following:

“Purchase requisition order: PR_000501 has been approved and new purchase order was created with number: ”.

So the second place holder: %Purchase Requisition.Purchase requisition lines.PurchId% has not been replaced correctly, although the Purchase order was created correctly.

The purchase order is created and field PurchReqLine.PurchId  is filled in in following code:

\Classes\PurchAutoCreate_PurchReq\createPurchLine
\Classes\PurchAutoCreate\create
\Classes\PurchAutoCreate_PurchReq\create
\Data Dictionary\Tables\PurchReqTable\Methods\setWorkflowState
\Classes\PurchReqWorkflowEventHandler\completed
\Classes\SysWorkflowEventDispatcher\raiseWorkflowEvent
\Classes\SysWorkflowEventDispatcher\onWorkflowCompleted

while the notification is sent a little later

\Classes\WorkflowDocumentField\substitutePlaceholderAsUser
\Classes\SysWorkflowEventDispatcher\sendNotifications
\Classes\SysWorkflowEventDispatcher\onWorkflowCompleted


As we can see from the  \Classes\PurchAutoCreate_PurchReq\createPurchLine the value of PurchLineReq.PurchId is updated between more than one pairs of “ttsbegin” and “ttscommit” and the query of the field is executed before the last “ttscommit” and the value will not be written into the database until the last “ttscommit” is executed (I have verified this by checking the database in SQL Server when debugging).

In method \Classes\WorkflowDocumentField\substitutePlaceholderAsUser we have following code

X++:
if (_userId == curuserid())    
 {     
 result = WorkflowDocumentField::substitutePlaceholder(args);     
 }     
 else     
 {     
 new RunAsPermission(_userId).assert();     
 // BP deviation documented     
 result = runas(_userId, classnum(WorkflowDocumentField), staticmethodstr(WorkflowDocumentField, substitutePlaceholder), args, _companyId);     
 CodeAccessPermission::revertAssert();     
 }
In the “runas” method, a new session will be created for the new logged user, and it will invoke the query method to get the value of the field of PurchLineReq.PurchId. Because the data is uncommitted(i.e. it doesn’t exist in table of sql server), we can’t get the value of the field PurchLineReq.PurchId and as a result in the notification message the placeholder “%Purchase Requisition.Purchase requisition lines.PurchId%” will be replaced with null and we can’t see the value, so the problem occurred.

Every time an application connects to SQL Server, a new connection (or SPID) is created. That means in the method Runas a new AX session is created and it will build a new connection to the database while searching a value in database but the new connection can’t read the uncommitted data of the old one, so I think it is right behavior that we can’t get the value by using Runas method.

This is why the placeholder:  %Purchase Requisition.Purchase requisition lines.PurchId% was not replaced correctly.

So the simple workaround is to change above code to not run with runas. Although you need to be aware that it can imply some security problem when you have record level security set up on table PurReqLine.

--author: Czesława Langowska Vliegen
--editor: Czesława Langowska Vliegen
--date: 22/Sep/2011




Источник: http://blogs.msdn.com/b/emeadaxsuppo...po-number.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.

Последний раз редактировалось Poleax; 22.09.2011 в 15:11. Причина: оформление
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
axinthefield: Managing Compliance with Microsoft Dynamics AX 2009 Blog bot DAX Blogs 0 10.06.2011 11:11
emeadaxsupport: Resolving some issues you may experience when creating an AX 2009 Role Center and Enterprise Portal Site using SharePoint Server/Foundation 2010 after installing Microsoft Dynamics AX 2009 SP1 hotfix 2278963 Blog bot DAX Blogs 1 24.09.2010 11:34
emeadaxsupport: You get a warning message when deploying the AX 2009 smmOpportunityReports report library Blog bot DAX Blogs 0 19.02.2010 05:07
emeadaxsupport: Unable to validate the AX 2009 Workflow Webservice URL on a Windows Server 2008 R2 x64 Blog bot DAX Blogs 0 05.01.2010 19:16
AX UK: Microsoft Dynamics AX 2009 Exam Deadline extended to 1st July 2009 Blog bot DAX Blogs 0 03.12.2008 19:05
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

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

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

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