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
Lynne Harding
Posts : 335
Join date : 2018-12-20

C# Opening A Form From A Search List Control Empty C# Opening A Form From A Search List Control

Mon 27 Jan 2020 - 8:52
I am trying to execute the following code from a search list...

const string SCREEN_NAME = “UDSCRASSOCWITNE”;
FWBS.Common.KeyValueCollection mySelectedItem = mySearchControl.CurrentItem(); long myAssocID = Convert.ToInt64(mySelectedItem[“Associd”].Value);

FWBS.Common.KeyValueCollection myKey = new FWBS.Common.KeyValueCollection(); myKey.Add(“Associd”, myAssocID);
FWBS.OMS.Associate myAssoc = FWBS.OMS.Associate.GetAssociate(myAssocID); object result = FWBS.OMS.UI.Windows.Services.ShowOMSItem(
SCREEN_NAME,
myAssoc, FWBS.OMS.EnquiryEngine.EnquiryMode.Edit, false, myKey);


...but I am always getting the same error...

There was a problem creating an object of type 'FWBS.OMS.Associate'.


The screen I am trying to open is registed as an Associate OMS Object and I have sent the property [myAssoc.Contact.Name] to a MessageBox and it displayed the correct name.
I then altered my code as the search list also returned the fileID as well as the AssocID...

const string SCREEN_NAME = “UDSCRFILMAIN”; FWBS.Common.KeyValueCollection mySelectedItem = mySearchControl.CurrentItem(); long myFileID = Convert.ToInt64(mySelectedItem[“Fileid”].Value);

FWBS.Common.KeyValueCollection myKey = new FWBS.Common.KeyValueCollection(); myKey.Add(“Fileid”, myFileID);
FWBS.OMS.OMSFile myFile = FWBS.OMS.OMSFile.GetFile(myFileID); object result = FWBS.OMS.UI.Windows.Services.ShowOMSItem(
SCREEN_NAME
, myFile, FWBS.OMS.EnquiryEngine.EnquiryMode.Edit, false, myKey);


This opened the screen correctly with no errors. I cannot see what is going wrong any ideas?
avatar
Lynne Harding
Posts : 335
Join date : 2018-12-20

C# Opening A Form From A Search List Control Empty Response from TR

Mon 27 Jan 2020 - 8:52
I’m sure I’ve had that error message before, but I can’t remember where or how I fixed it unfortunately!


I’d start with the searchlist, make sure that assocID is in the ReturnFields.
Also, if the code is running off a searchlist button, make sure that the button has an Action of None, as this may interfere with the code.

If associd is in the ReturnFields then check the UDSCRASSOCWITNE screen. Have a look in the data builder and see how it’s setup: Type:Object
Source: FWBS.OMS.Associate
Parameter: associd, with a bound value of %associd%, Type of System.Int64 and a SQL Parameter of ASSOCID


I don’t know if the parameters are case sensitive, but try it in lower case to rule it out, including how you add it to the KVC (myKey.Add(“associd”, myAssocID)) Comment any code in the EnquiryLoaded or Rendered events of UDSCRASSOCWITNE and see if that fixes it.
If you still have no joy try the following code to call the screen


FWBS.OMS.UI.Windows.Services.Wizards.GetWizard(“UDSCRASSOCWITNE”, _myAssoc, FWBS.OMS.EnquiryEngine.EnquiryMode.Edit, _ myKey);
avatar
Lynne Harding
Posts : 335
Join date : 2018-12-20

C# Opening A Form From A Search List Control Empty Re: C# Opening A Form From A Search List Control

Mon 27 Jan 2020 - 8:53
Can you try this overload instead
public static object ShowOMSItem(string code, object parent, FWBS.OMS.Interfaces.IEnquiryCompatible businessObject, Common.KeyValueCollection param)

parent will be null businessObject your Associate
param can be null as your passing in the businessObject
When using the overload that only takes a parent the enquiry form tries to construct a new object even if you specify EnquiryMode.Edit based on the information it can gather from the parent.
avatar
Lynne Harding
Posts : 335
Join date : 2018-12-20

C# Opening A Form From A Search List Control Empty Re: C# Opening A Form From A Search List Control

Mon 27 Jan 2020 - 8:53
Your solution worked perfectly. My code now looks like this...

const string SCREEN_NAME = “UDSCRASSOCWITNE”;
FWBS.Common.KeyValueCollection mySelectedItem = mySearchControl.CurrentItem(); long myAssocID = Convert.ToInt64(mySelectedItem[“Associd”].Value);
FWBS.OMS.Associate myAssoc = FWBS.OMS.Associate.GetAssociate(myAssocID); object result =
FWBS.OMS.UI.Windows.Services.ShowOMSItem(SCREEN_NAME
, null, myAssoc, null); mySearchControl.Search();
Sponsored content

C# Opening A Form From A Search List Control Empty Re: C# Opening A Form From A Search List Control

Back to top
Permissions in this forum:
You cannot reply to topics in this forum