Process Mapping Logo

Process Mapping - Forums

Sharing 19 years of knowledge and experience

 
Metastorm BPM forums
Sign up Latest Topics
 
 
 


Reply
  Author   Comment  
royster

Senior Member
Registered:
Posts: 74
Reply with quote  #1 
Yes I have been racking my brains out on this as my SQL command was returning 0 records.

Did a little WriteToLog on the SQL String and it turns out that ProcessContext.FormName is empty when the form is being saved. This is more than a bit of a pain in the backside.

*********Addendum*********

I am also finding that in the Form.Save code page that I do not seem to be able to set a Process variable to a new value. For example I am trying to set an integer value that controls a Status field, but no matter what value I attempt to set it to, the variable does not seem to change.

0
Jerome

Avatar / Picture

Guru
Registered:
Posts: 5,507
Reply with quote  #2 
What about ProcessContext.UserForm?
__________________
Post an example, and we will have a much better idea what the problem is. In about 90% of posts, the problem is one of communication. Examples bridge that gap.
0
Jerome

Avatar / Picture

Guru
Registered:
Posts: 5,507
Reply with quote  #3 
Quote:
Originally Posted by royster
I am also finding that in the Form.Save code page that I do not seem to be able to set a Process variable to a new value. For example I am trying to set an integer value that controls a Status field, but no matter what value I attempt to set it to, the variable does not seem to change.

I assure you that you can. You must be doing something else. How a are you setting it?

__________________
Post an example, and we will have a much better idea what the problem is. In about 90% of posts, the problem is one of communication. Examples bridge that gap.
0
royster

Senior Member
Registered:
Posts: 74
Reply with quote  #4 
Hi Jerome
I'm using processcontext.formname during the form life cycle, but on form save, this returns nothing. Not A big deal as I can force the value, but when I try to set the process variable, during the same form save event, it just won't save the new value.
0
Jerome

Avatar / Picture

Guru
Registered:
Posts: 5,507
Reply with quote  #5 
How are you setting the process variable? I do it all the time and have never had a problem.
__________________
Post an example, and we will have a much better idea what the problem is. In about 90% of posts, the problem is one of communication. Examples bridge that gap.
0
royster

Senior Member
Registered:
Posts: 74
Reply with quote  #6 
I would expect not to have a problem. Here is what I am doing.

I have 3 forms that work off chained actions. Because we want users to be able to edit some data and come back to each form later, we do not have any field set up as required fields. I have a form save event that looks up a database for the current map, action and form (which is where my initial issue came from), pulls out the field names that are required, and works out whether a value has been entered for each required field. If so, a variable, which initiates to 0, is set to 2 else set to 1. When I chain the action, my variable remains at 0. In theory my variable must be set to 2 or 1, according to the code, and at no point does any error occur.

This is obviously driving me up the wall.
0
Jerome

Avatar / Picture

Guru
Registered:
Posts: 5,507
Reply with quote  #7 
For dynamic chained actions I find you must set the variable on the form before submitting. This is undocumented, of course. I usually set a field with the client script in 'commit action' buttons.
__________________
Post an example, and we will have a much better idea what the problem is. In about 90% of posts, the problem is one of communication. Examples bridge that gap.
0
royster

Senior Member
Registered:
Posts: 74
Reply with quote  #8 

Finally managed to sort this. Your ProcessContext.UserForm worked and gave a form name, it also seems to have sorted the issue with setting process variable value. I'm more than a touch miffed that ProcessContext.FormName returns and empty string on the form save event, but not otherwise. It is very strange.

Chain action is being set client side, it is inconsistent when you do it server side, I find.

Anyway...more than happy to share my dynamic validation code server side processing.

bool RequiredMissing = false;
int i = 0;

//SQL to pull form field names from a table for the current action that are required to be filled in
string sql = String.Format("SELECT EFIELDNAME FROM ACTION_FORM_FIELDS WHERE EMAPNAME = '{0}' AND EACTIONNAME = '{1}' AND EFORMNAME = '{2}' AND ISREQUIRED = 'Y' ", ProcessContext.ProcessName, ProcessContext.ActionName, ProcessContext.UserForm);

DataTable dt = Mstm.SelectSql(new MetastormDefault(), sql).GetDataTable();

for (i=0; i<dt.Rows.Count; i++)
{
    //Cycle through the datatable and compare each required field to see if a value has been entered
    string s = this.Current.GetField(dt.Rows[i][0].ToString()).DataValue.ToString();

    if ((s == "") || (s == "0")) RequiredMissing = true;
}
 
dt.Dispose();

0
Jerome

Avatar / Picture

Guru
Registered:
Posts: 5,507
Reply with quote  #9 
1. use SQLArg() to add arguments instead of formatting strings. Formatting strings will fail (or require a loyt more work) when text with quotes in or dates are used. In addition, the database will treat SQL with arguments much more intelligently by caching execution plans.

2. I would add the condition you test for in code as a condition in the SQL. You then only have to see if any rows are returned, using COUNT(*). Much less code!

__________________
Post an example, and we will have a much better idea what the problem is. In about 90% of posts, the problem is one of communication. Examples bridge that gap.
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:


Create your own forum with Website Toolbox!