I am new with Elsa workflow and I am trying to set Context ID from the designer by the id I get from HTTP Endpoint I created but I do not the syntax that I should use. I tried the JS syntax but it return an error for me.
context.ContextId = WorkflowContext.Id;
First of all, you have to understand how elsa loading context work.
when you enter the type of your workflow context it automatically make loading for your workflow Context with null value in context Id.
so you can not access your Workflow Context so what should you do?
you have first to access your HTTP Endpoint body to get your the information that you want.
using JS syntax
input.Body.Id
then you have to reload your workflow context in the next activity
Related
I am trying to recover the value of the user who is logged on the site but I am currently blocked.
I use .Net core 2.1 with EF Core. I created a context called jakformulaireContext and also jakformulaireUser.
I have to send an email to confirm that a user has registered to an event but I can not find the piece of code allowing me to recover the field "email" which is in the database.
In the scaffolding part which contains the Register controller I succeeded because I would recover the value of the field "email" but here I am in a controller that is located outside of Account.
So I tried to do a find but it does not seem to be the right method because I get a Task <> while I just want a string.
var user = _userManager.FindByEmailAsync ("jon#live.be");
Would you have a solution?
If you have an async method it will return a Task. So what you need to do is wait until that method is finished. The way to do it is:
var user = await _userManager.FindByEmailAsync ("jon#live.be");
More information about async/wait
Is there any way to set the value of a workflow's InArgument parameter from another workflow when launching it programmatically ?
Here's how I launch it:
var req = new ExecuteWorkflowRequest { WorkflowId = new Guid(WorkflowGuids.RenewalWorkflowId), EntityId = theContact.Id };
service.Execute(req);
I can catch the EntityId value back in the other workflow in context.PrimaryEntityId but I am at a loss as to how to populated the arguments and retrieve them on the other side.
Is this possible ? Thanks.
InArgument are defined at step level, not at workflow level.
When a workflow is executed (by a trigger, on-demand or by code) you have the record Id.
You can create a custom workflow activity to fetch other data related (or not connected at all) with your record Id and make it as OutArgument so will be available as input for the InArgument you want to set.
i have assigned workflow as usual. i tried following code but didn't get any item....please share any sample code if you have any or help me get items
Database masterDatabase = Factory.GetDatabase("master");
Item currentItem = masterDatabase.Items["/sitecore/content/Home"];
IWorkflow workflow = masterDatabase.WorkflowProvider.GetWorkflow(currentItem);
WorkflowState state = workflow.GetState(currentItem);
Try to use SecurityDisabler
using (new SecurityDisabler())
{
var db= Factory.GetDatabase("master");
var item = db.Items["/sitecore/content/Home"];
// getting the item's workflow reference
var wf = this.database.WorkflowProvider.GetWorkflow(item);
// here we need either to login as a user with appropriate permissions
// to have access to workflow states/commands or disable security
wf.Start(item);
}
That API is only going to work in a site context where workflow is enabled. Either enable it in your <sites> config or use a context switching block around your code.
I am writing a WPF client application and use WCF Data Service to communicate with a database. I have the following situation: I add a new Policy, it has an attached object House and each House has an Address. In standard Entity Framework application it wasn't a problem but here I need to add relationships between entites. This is my code:
context.AddToPolicySet(Policy);
context.AddToAdressSet(Address);
context.AddRelatedObject(Address, "HouseSet", House);
context.AddRelatedObject(Policy, "HouseSet", House); // !!!!!!!!!!!!
Policy.HouseSet.Add(House);
House.PolicySet = Policy;
Address.HouseSet.Add(House);
House.AdressSet = Address;
Now, I understand that the context is already tracking the entity. But how to solve this problem? If I remove the fourth line then I get the error "Insert statement violetes foreign key constraint...". It seems to me that I need to attach a House to the Policy and a House to the Address. But my way is obviously the wrong way. What is the right one? :)
Use the AddLink method:
context.AddLink(Policy, "HouseSet", House);
EDIT
It appears to be
context.SetLink(House, "PolicySet", Policy);
My "Register" page used to work, until I started using FormsAuthentication and FormsAuthenticationTicket to login.
Now on Register, it fails when checking if an email already exists in the database, on this line
if (Global.DC.Users.Where(x=>x.Email == Email).Count() > 0)
return "The email address already exists in the database";
with this error message
System.Data.SqlClient.SqlException:
Login failed for user ''.
Does anyone know how to solve this? Thanks in advance.
Looks like the SQL login is invalid. I would check your connection string to see if that has changed, and if not, I would validate that the SQL Login and Database User is configured correctly.
Typically you may not realise this has happened if you are changing how your DataContext is being called, if you used to explicitly test it using a specific connection string, or create it with the default constructor (new ....DataContext()). Using the default constructor normally uses the design time connection string configured in the Settings.settings project item which stores the connection string name to reference in your web.config configuration file. Are you still calling it the same way?
On another note, I noticed you're calling your DataContext through your Global class. This is generally considered a bad design, and you should really consider using a unit-of-work` approach to data access, e.g., instantiate and release your context after you're finished with it:
using (var context = new DataContext()) {
// Do work here.
}
And another quick one, its more efficient to using Any instead of Count as using Count causes the entire enumerable to be enumerated to get the result, where as Any will fall out at the first valid instance.