- How to set the status of customize entity automatically??
- Posted by Carrie on June 20th, 2006
Hi,
Last time i create an entity to capture expense cost associated with
opportunity. When the opportunity is being closed for either win/lost, i wish
that the expense attached to the opportunity is being updated automatically.
I have tried to accomodate this by using workflow. However till now i have
not found the way. the condition that i used when expense entity is being
created, check the opportunity status then update the status to inactive.
However i did not see the status of expense being updated.
Is there a workaround beside using workflow? How to do it?
Carrie
- Posted by Ben on June 21st, 2006
Carrie,
The workflow is the best way to achieve what you are trying to do. Why
about the workflow is failing?
Thanks,
Benjamin Pirih
"Carrie" wrote:
- Posted by Carrie on June 22nd, 2006
Hi Ben,
Well i do not really sure why it failed. My assumption is the condition that
i put was not really correct.
When expense is created
if Opportunity.status <> Open
then
change state to inactive
By default, when expense is created,the status of opportunity is open
already. So i do not think this workflow should run right?? But what i notice
is that whenever i created the new expense, this workflow is executed with no
action.
Then i was thinking to use opportunity workflow. the condition is when
opportunity change the status to won, then update customize entity status.
The problem that i face here is i do not know whether the attribute on update
change can be added to the entity that i refer to. By default the change
update for opportunity workflow consists of account, contact, owner and
opportunity.
Is there a way to add update change attribute on workflow action???
Thx,
Carrie
"Ben" wrote:
- Posted by Ben on June 22nd, 2006
Hi Carrie,
Have you seen this article?
http://www.mscrmguy.com/hols/assembly/
It uses vs.net 2005, shouldn't matter, and should send you in correct
direction. As for the logic of the work flow, I would just fire your action
whenever the state is changed. In the worflow procedure you can check the
entity parameters to see the status, then perform your logic if nesscary. I
hope this is helpful.. Thanks, Ben
"Carrie" wrote:
- Posted by Carrie on June 23rd, 2006
Hi Ben,
Thanks a lot for the reference. I have created the .dll file and upload it
on the same directory as the workflow assembly. I also modify the
workflow.config file as mentioned on the documentation. However when i start
the Workflow manager after i attached my .dll and web.config, i encounter
error " Workflow manager cannot start. THis could be because the workflow
configuration file is corrupted, or MSCRM WF service cannot access the
configuration file."
In the log it stated "MSCRMWorkflowHost: The description for Event ID ( 0 )
in Source ( MSCRMWorkflowHost ) cannot be found. The local computer may not
have the necessary registry information or message DLL files to display
messages from a remote computer. The following information is part of the
event: '<', hexadecimal value 0x3C, is an invalid attribute character. Line
48, position 4.."
Any idea??
Thx,
Carrie
"Ben" wrote:
- Posted by Ben on June 23rd, 2006
Sounds like you have a problem with your C:\Program Files\Microsoft
CRM\Server\bin\assembly\workflow.config file..
Wanna post it so we can look at it??
Thanks,
"Carrie" wrote:
- Posted by Carrie on June 26th, 2006
Hi Ben,
The error was gone already. Seems that i missconfigured the parameters.
However, i still have not achieved my goal yet. I created Opportunity WF as
wait condition and when opportunity status <> open then executed call
assembly for customized rll that i made. I created opportunity and added the
expense associated to the Opportunity, the WF was on running process which
was intended behaviour. Then when i closed the opportunity to lost, the WF
status became Finished and the log showed action is ok. Then i checked back
into expense status. It's still active.
My knowledge on coding is really limited. Here is the coding that i used on
my rdl
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace WorkingWithCRM
{
public class CustomAssembly
{
public int setInteger(int Inactive)
{
return Inactive;
}
}
}
Then on my web.config, i put
<workflow.config xmlns="http://microsoft.com/mscrm/workflow/"
allowunsignedassemblies="true">
<methods>
<method name="Set Status"
assembly="WorkingWithCRM.dll"
typename="WorkingWithCRM.CustomAssembly"
methodname="setInteger"
isvisible="1"
timeout="7200">
<parameter name="Status" datatype="picklist" entityname="new_expense"
attribute="statecode"/>
<result datatype="picklist" entityname="new_expense"
attribute="statecode"/>
</method>
Did i miss something???
Thx,
Carrie
"Ben" wrote:
- Posted by Ben on June 26th, 2006
Carrie, I would attack this problem by doing the following.. I really do not
understand the custom code that you have below i.e. the workingwithcrm
class. Y your going to need more variables then just the status, try
returning @all so you can get a feel of your working data... i.e. you will
want the parentobjectid also?
1st Create your custom .dll with a empty method, Reference this custom
method using the workflow config. Then create the custom rule to fire using
the workflow manager.. In this case it sounds like you want when opportunity
change status..
2nd Attach the debugger and make sure that your method is correctly firing.
i.e. you can perform the action and your dll will be succesffully linked and
executed.
3rd In your custom dll parse the xml information passed from the workflow
engine and perform custom logic. i.e. if this is an update and the new state
is closed then... do your operations..
Good Luck,
Ben
"Carrie" wrote:
- Posted by Carrie on July 3rd, 2006
Hi Ben,
First of all, sorry i still do not get your point yet. I have been trying to
understand the logic here. For the condition, i can just use opportunity
workflow right using the wait condition. So if opportunity change status to
won/lost then execute the rll.
So in my rll, i only need to return the value of statecode of my customize
entity right? Here are the part that i am still blurr. Hopefully you can
explain me. In the link that u provided my before
(http://www.mscrmguy.com/hols/assembly/), under the 3rd slides, declaring the
class. Since rll that i need is only retrieve value from statecode and i
check it on DB the type of statecode, it's integer. So should i use integer
instead of string?
When configuring workflow config> entity name, i just add the customize
entity that refer in the rll?
Carrie
"Ben" wrote:
- Posted by Atul Gadre on September 19th, 2006
Hi Carrie,
I am trying to update the state of a entity programatically with the
follwing code.
Can you help me in this? i am getting error and the entity's state is not
updated.
Dim objrequest As New SetStateNew_ORequest
objrequest.EntityId = New Guid(sRowID)
objrequest.New_ORequestState = New_ORequestState.Inactive
objrequest.New_ORequestStatus = 1
Dim objrespo As SetStateNew_ORequestResponse =
CType(wsCRMService.Execute(objrequest), SetStateNew_ORequestResponse)
regards,
"Carrie" wrote: