Mattersphere Developers Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Go down
avatar
Admin
Admin
Posts : 122
Join date : 2018-12-17
https://mattersphere-devs.forumotion.com

Pass An Array/Kvc From A Wizard To Taskflow Empty Pass An Array/Kvc From A Wizard To Taskflow

Tue 28 Jan 2020 - 9:57
I would like to return an Array/KVC from a Wizard to taskflow, but I'm not sure how to access the data returned to taskflow. I need to know how the Wizard should be called. for example

Code:

System.Data.DataTable _result = FWBS.OMS.UI.Windows.Services.Wizards.GetWizard(
    "UDWZDPOCSERVED",CurrentFile ,FWBS.OMS.EnquiryEngine.EnquiryMode.Edit, _kvc) as System.Data.DataTable;
or
Code:

Object _result = FWBS.OMS.UI.Windows.Services.Wizards.GetWizard(
    "UDWZDPOCSERVED",CurrentFile ,FWBS.OMS.EnquiryEngine.EnquiryMode.Edit, _kvc);

The Array/KVC is populated programmatically on the finishing event of the wizard,and it's size will be dynamic. I need the set the array/KVC as something that needs to be returned but not sure how this is done. I then need to know how the data can be extracted from the Object/DataTable back in taskflow.any help will be appreciated!
many thanks
____________________________________________________________________________________________________________________________________________________
Hi Mike,
You could add a component control to you wizard with its datatype set to System.Object you can then set its value to your KVC when after the wizard has been processed you will be returned a datatable containing 1 row for each control on the enquiry. If your component is called 'MyData' then your code to get the data would be similar to the following.

Code:

System.Data.DataTable _result = FWBS.OMS.UI.Windows.Services.Wizards.GetWizard("UDWZDPOCSERVED",CurrentFile ,FWBS.OMS.EnquiryEngine.EnquiryMode.Edit, _kvc) as System.Data.DataTable;
if (_result != null)
//will be null if wizard was cancelled
{
    KeyValueCollection kvc = _result.Rows[0]["MyData"] as KeyValueCollection as KeyValueCollection;
}
Regards Richard
____________________________________________________________________________________________________________________________________________________
thanks for that, I've almost got it now. I have set the component to a System.Object, and assigned it the value of a KVC (a searchlist selected items collection)
Code:

FWBS.OMS.UI.Windows.ucSearchControl s = EnquiryForm.GetControl("schAssociate") as FWBS.OMS.UI.Windows.ucSearchControl;
EnquiryForm.GetIBasicEnquiryControl2("cmpAssocReturn").Value = s.SelectedItems;

//then in the task flow I write the following
FWBS.Common.KeyValueCollection _kvc = new FWBS.Common.KeyValueCollection();
_kvc.Add("ASSOCTYPE", "LAY");
_kvc.Add("FILEID", CurrentFile.ID);
System.Data.DataTable _result =
    FWBS.OMS.UI.Windows.Services.Wizards.GetWizard("UDWZADDSELASSOC",CurrentFile,FWBS.OMS.EnquiryEngine.EnquiryMode.Add,false,_kvc) as System.Data.DataTable; KeyValueCollection kvc =
    _result.Rows[0]["cmpAssocReturn"] as KeyValueCollection as KeyValueCollection;
for (int i=0; i{ MsgBox(kvc[i].Value.ToString(), i.ToString()); i++;}

I'm getting an error because the KVC object is null. Can you see where I am going wrong? The wizard is not bound or registered and _result does not come back null. many thanks
____________________________________________________________________________________________________________________________________________________
Hi Mike, After some digging I have found it is not possible to pass the KVC as a System.Object. It is possible to pass through a HashTable or an ArrayList though if the components DataType is set to one of them. In my testing I have set the components datatype to System.Collections.ArrayList (not in the list but can be typed). Finishing Event
Code:

FWBS.OMS.UI.Windows.ucSearchControl s = EnquiryForm.GetControl("schAssociate") as FWBS.OMS.UI.Windows.ucSearchControl;
System.Collections.ArrayList list = new System.Collections.ArrayList();
list.Add(s.SelectedItems);
EnquiryForm.GetIBasicEnquiryControl2("cmpAssocReturn").Value = list;

//Task Flow
FWBS.Common.KeyValueCollection _kvc = new FWBS.Common.KeyValueCollection();
_kvc.Add("ASSOCTYPE", "LAY");
_kvc.Add("FILEID", CurrentFile.ID);
System.Data.DataTable _result = FWBS.OMS.UI.Windows.Services.Wizards.GetWizard(
    "UDWZADDSELASSOC",CurrentFile,FWBS.OMS.EnquiryEngine.EnquiryMode.Add,false,_kvc) as System.Data.DataTable;

System.Collections.ArrayList returnVals = result.Rows[0]["cmpAssocReturn"] as System.Collections.ArrayList;
KeyValueCollection kvc = returnVals[0] as KeyValueCollection;

It's a little more work but does work.
Regards Richard.
____________________________________________________________________________________________________________________________________________________
I've found a more efficient method. Use the datatype of System.Object and code from my original answer but to set the value of the component use the following code on the finishing event.
Code:

EnquiryForm.Enquiry.SetValue("cmpAssocReturn",s.SelectedItems);
This method sets the value directly into the underlying data table and the KVC won't get nulled.

Regards Richard
____________________________________________________________________________________________________________________________________________________
Hi,
I tried your first suggestion with the component as a System.Collections.ArrayList and the value set like this on the finishing event...
Code:

System.Collections.ArrayList list = new System.Collections.ArrayList();
list.Add(s.SelectedItems);
EnquiryForm.GetIBasicEnquiryControl2("cmpAssocReturn").Value = list ;

//and in taskflow
FWBS.Common.KeyValueCollection _kvc = new FWBS.Common.KeyValueCollection();
_kvc.Add("ASSOCTYPE", "LAY");
 _kvc.Add("FILEID", CurrentFile.ID);
System.Data.DataTable _result = FWBS.OMS.UI.Windows.Services.Wizards.GetWizard(
    "UDWZADDSELASSOC",CurrentFile,FWBS.OMS.EnquiryEngine.EnquiryMode.Add,false,_kvc) as System.Data.DataTable;

System.Collections.ArrayList returnVals = result.Rows[0]["cmpAssocReturn"] as System.Collections.ArrayList;
KeyValueCollection kvc = returnVals[0] as KeyValueCollection;
Using this code the KVC is null.
Using your second suggestion with the component set to a System.Object, and the value added like this...
Code:

EnquiryForm.Enquiry.SetValue("cmpAssocReturn",s.SelectedItems);
and with the taskflow remaining the same, I receive an ORNS error because in the Taskflow the returnVals ArrayList is null.

any idea what could be wrong? again many thanks for your help.
____________________________________________________________________________________________________________________________________________________
Using the second method the returnVals will be a KeyValueCollection could that be the problem?
If that is not the problem could you try creating your own KVC in the finishing event and seeing if that gets passed through? I haven't tried it with a searchlists selected items and I am wondering if they have already been disposed of.
Code:

KeyValueCollection kvc = new KeyValueCollection();
kvc.Add("Item1",1);
kvc.Add("Item2",2);
EnquiryForm.Enquiry.SetValue("comp",kvc);
____________________________________________________________________________________________________________________________________________________
I've changed the code around a bit and this now works.In the wizard I have this, with the component as a System.Object...
Code:

FWBS.OMS.UI.Windows.ucSearchControl s = EnquiryForm.GetControl("schAssociate") as FWBS.OMS.UI.Windows.ucSearchControl;
KeyValueCollection assocList = new KeyValueCollection();
int i=1;
foreach (KeyValueCollection _kvc in s.SelectedItems)
{
    assocList.Add(_kvc["AssocID"]);
    System.Windows.Forms.MessageBox.Show(_kvc["AssocID"].Value.ToString(), i.ToString());
    i++;
}
EnquiryForm.Enquiry.SetValue("cmpAssocReturn",assocList);

//and in the taskflow I have this...
Code:

KeyValueCollection kvc = _result.Rows[0]["cmpAssocReturn"] as KeyValueCollection;
this does not return null.I can then access the assocID's like so
Code:

for (int i=0; i{ MsgBox(kvc[i].Value.ToString(), i.ToString());}

many thanks for all your help with this.
Mike
Back to top
Permissions in this forum:
You cannot reply to topics in this forum