My forms have one to many relationships which isn't possible right now for contour. Therefore, i had to create a custom workflow to add to my table. It doesn't seem like it is even calling the workflow i created. What did i do wrong? I had to hard code and it still isn't inserting. I am connecting to the database using the EF.
Yes, it was showing up in the dropdown. And I replace every GUID i find in the internet with a new one from an online generator. I have to thank you with the other site you have. I based my code on a tutorial you created about score mapping. http://www.nibble.be/?p=83
I got it to work. EF needed a primary key in the linking table. My other question would be, Is this the best way to get the values for every field? And also, the variable message holds the new ID #. How do i show this in a results page? Again, this is a working code. Only pasted this method. the classes variable holds IDs from a checkbox.
Workflow Add to EF
My forms have one to many relationships which isn't possible right now for contour. Therefore, i had to create a custom workflow to add to my table. It doesn't seem like it is even calling the workflow i created. What did i do wrong? I had to hard code and it still isn't inserting. I am connecting to the database using the EF.
namespace Blob.Umbraco.workflow
{
public class ClassWF : WorkflowType
{
public ClassWF()
{
this.Id = new Guid("7D86C6E1-5831-491D-B1E5-70520FBC75E2");
this.Name = "Class Workflow";
this.Description = "Class Workflow";
}
[Setting("Registrant Name",
control = "Umbraco.Forms.Core.FieldSetting.FieldPicker")]
public string RegistrantName { get; set; }
[Setting("Email",
control = "Umbraco.Forms.Core.FieldSetting.FieldPicker")]
public string Email { get; set; }
[Setting("Membership Type",
control = "Umbraco.Forms.Core.FieldSetting.FieldPicker")]
public string MemType { get; set; }
[Setting("Classes",
control = "Umbraco.Forms.Core.FieldSetting.FieldPicker")]
public string FClasses { get; set; }
public override List<Exception> ValidateSettings()
{
List<Exception> exceptions = new List<Exception>();
return exceptions;
}
public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
{
//string [] split = FClasses.Trim().Split(' ');
int [] classes = new int[1];
//for(int ii = 0; ii < classes.Length; ii++)
//{
// classes[ii] = 0;
// if(Int32.TryParse(split[ii], out classes[ii]) == false){
// classes = new int[0]; //set to zero
// break;
// }
//}
classes[0] = 5;
string message = FitnessRegistrationBLL.InsertRegistrant("d", "3", "f", "asdf", "asdf", classes);
//string message = FitnessRegistrationBLL.InsertRegistrant(RegistrantName, PhoneNo, StudentNo, Email, MemType, classes);
if(message.Contains("Error"))
return WorkflowExecutionStatus.Failed;
else
return WorkflowExecutionStatus.Completed;
}
}
}
Any input would do. Thank you.
Comment author was deleted
Does it show up in the workflow type dropdown? And did you change the GUID to something unique?
Hello Tim,
Yes, it was showing up in the dropdown. And I replace every GUID i find in the internet with a new one from an online generator. I have to thank you with the other site you have. I based my code on a tutorial you created about score mapping. http://www.nibble.be/?p=83
I got it to work. EF needed a primary key in the linking table. My other question would be, Is this the best way to get the values for every field? And also, the variable message holds the new ID #. How do i show this in a results page? Again, this is a working code. Only pasted this method. the classes variable holds IDs from a checkbox.
public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
{
string _RegName = "";
string _StudentNo = "";
string _PhoneNo = "";
string _Email = "";
string _MemType = "";
List<int> classes = new List<int>(); //foregin key holder
foreach (RecordField rf in record.RecordFields.Values)
{
string val = rf.Values.First().ToString().Trim();
if (rf.Field.Id == new Guid(RegistrantName))
{
_RegName = val;
}
else if (rf.Field.Id == new Guid(StudentNo))
{
_StudentNo = val;
}
else if (rf.Field.Id == new Guid(PhoneNo))
{
_PhoneNo = val;
}
else if (rf.Field.Id == new Guid(Email))
{
_Email = val;
}
else if (rf.Field.Id == new Guid(MemType))
{
_MemType = val;
}
else if (rf.Field.Id == new Guid(FClasses))
{
string[] split = val.Split(',');
foreach (string s in split)
{
int ccid = 0;
if (Int32.TryParse(s, out ccid))
{
classes.Add(ccid);
}
else
{
break;
}
}
}
}
string message = FitnessRegistrationBLL.InsertRegistrant(_RegName, _PhoneNo, _StudentNo, _Email, _MemType, classes);
return WorkflowExecutionStatus.Completed;
is working on a reply...