Calling business process with parameters from Anonymous web service
Hi,
I'm trying to call a bp from a webservice that doesn't use authentication so i'm following the example provided:
https://community.bpmonline.com/articles/web-service-without-authorizat…
When i try to set the parameter of the business process i get the following error:
Terrasoft.Common.InvalidObjectStateException: missing property "UsrNewInsertedEntityId" of type "ProcessComponentSet"
var UserConnection = this.SystemUserConnection; var manager = UserConnection.ProcessSchemaManager; var processSchema = manager.GetInstanceByName("UsrIncomingEntity"); var process = processSchema.CreateProcess(UserConnection); if (processSchema.Parameters.ExistsByName("usrNewInsertedEntityId")) { process.SetPropertyValue("UsrNewInsertedEntityId", msgId); } process.Execute(UserConnection);
Do i need to set anything on the BP process property?
Like
Hi Luciano,
Please advise if you created your UsrIncomingEntity business process beforehand and if you added the usrNewInsertedEntityId parameter into it. Make sure you do that first.
If you did it, kindly provide us with the whole code so that we could have a look into it and advise on possible errors.
Thanks
Hello Luciano,
Basically, the code should work in appropriate way. As S.Kobizka said, you should check that business process with code "UsrIncomingEntity" exists and has "usrNewInsertedEntityId" parameter.
Also, I recommend try to choose "compile all" option in configuration, it may help because source code will be regenerated.
If you will have further difficulties, please, send the entire code of webservice and screenshots of the businessprocess.
Regards,
Alex
Alex_Tim,
Hi,
Thank you both for the answer, the BP exists prior to the webservice as well as the parameter. If i debug the code both the bp and the parameter are available to inspect. As soon as the line:
process.SetPropertyValue("UsrNewInsertedEntityId", msgId);
is executed i get the error.
I'll try the compile all option and then retest to see if that helps.
Thanks
Luciano De Munno,
It seems that the reason of the issue is that msgId variable and UsrNewInsertedEntityId parameter in business process have different types. Please make sure that msgId is Guid and UsrNewInsertedEntityId is unique identifier http://prntscr.com/n0yt77
Regards,
Alex
Alex_Tim,
Hi Alex,
Thank you for the answer, i checked and msgId is a Guid and the parameter UsrNewInsertedEntityId has the type "Unique Identifier". AS far as i know that's the correct type i can try chaning both the string and text and then converting to guid inside the process to see if that helps.
Same thing, now i'm sending a string and expecting a string but the error is the same.
Hello Luciano,
Here is the example of how to start business process with parameter from server side code.
If you will have further difficulties, please contact support team support@bpmonline.com
using Terrasoft.Core;
using Terrasoft.Core.Process;
using Terrasoft.Core.Process.Configuration;
ProcessSchema schema = UserConnection.ProcessSchemaManager.GetInstanceByName("LeadManagement");
//schema = UserConnection.ProcessSchemaManager.GetInstanceByUId(leadManagementProcessUId);
//different engines for interpretable and compiled BP
bool canUseFlowEngine = ProcessSchemaManager.GetCanUseFlowEngine(UserConnection, schema);
if(canUseFlowEngine) {
var flowEngine = new FlowEngine(UserConnection);
var param = new Dictionary<string, string>();
param["LeadId"] = Entity.Id.ToString();
flowEngine.RunProcess(schema, param);
} else {
Process process = schema.CreateProcess(UserConnection);
process.SetPropertyValue("LeadId", Entity.Id);
process.Execute(UserConnection);
}
Hi Alex,
The FlowEngine part did the trick. Thank you so much