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

Add associates based on variable Empty Add associates based on variable

Thu 23 Jan 2020 - 14:04
We would like to be able to add associates to a file based on a variable initiated by a button click on a file form. So for example
Code:

WHERE FILE.variable = "Barclays" associate all Contacts WHERE (CONTACT.NAME = "BARCLAYS" and CONTACT TYPE = "BANK")
Any help very much appreciated
____________________________________________________________________________________________________________________________
Hi Cliff, You might wish to try something along the lines of the method below (assuming the form is on a tab in the Matter screen):
Code:

//get the file object for the form
_file = Enquiry.Object as FWBS.OMS.OMSFile;

//create the new Associate for the file passing in the Contact ID, file object, associated format.
FWBS.OMS.Associate newAssoc = new FWBS.OMS.Associate(FWBS.OMS.Contact.GetContact(<contID>)),_file, <AssocFormat>);
If the form is not on a tab, you might want to pass the file object to the form and access it via the ReplacementParameters of the form before adding any Associates. Hope this helps.
____________________________________________________________________________________________________________________________
Hi Many thanks for your reply. We have got as far as below but are probably making some elementary errors as it will not compile:
Code:

//Add associate/s to file where contact name = value in AUTH field on file form
protected virtual void NETButton1_Click(object sender, System.EventArgs e)
{
   string plan = EnquiryForm.GetIBasicEnquiryControl2(“AUTH”,EnquiryControlMissing.Exception).Value.ToString();
   //Get Contact object
   FWBS.OMS.Contact value = Enquiry.Object as FWBS.OMS.Contact;
   // For each contact where Contact Name = “AUTH” add that contact as an associate to current file
   foreach(FWBS.OMS.Contact Contact in Contact??)
   {
       if (Contact.Name == plan)
       {
           //Add associate
       }
    }
}
____________________________________________________________________________________________________________________________
Looking quickly without the compilation error, You would need to search for contacts to be able to enumerate them. I am not sure on the specifics of what you are trying to do.
____________________________________________________________________________________________________________________________
Hi

Ok i have created a sample package that will bulk add Associates to a File
____________________________________________________________________________________________________________________________
Basically the form has a Collection Editor linked to a DataList in my case lists all the contacts but you could add your own filter to that datalist if you have many contacts.

A Button that Adds the selected Contacts plus a couple of required fields that are required by the Associate object. The Associate Type and Associate Heading

Code:

protected virtual void btnAdd_Click(object sender, System.EventArgs e)
{
    FWBS.OMS.UI.Windows.eCLCollectionSelector source = EnquiryForm.GetControl("CollectionManage1") as FWBS.OMS.UI.Windows.eCLCollectionSelector;
    FWBS.OMS.OMSFile file = FWBS.OMS.UI.Windows.Services.SelectFile();
    if (file == null)
    {
        return;
    }
    foreach (System.Data.DataRow dr in source.SelectedItems.Rows)
    {
        long contid = Convert.ToInt64(dr["contid"]);
        FWBS.OMS.Contact contact = FWBS.OMS.Contact.GetContact(contid);
        FWBS.OMS.Associate **** = new FWBS.OMS.Associate(contact,file,FWBS.OMS.AssociateType.GetAssociateType(
            Convert.ToString(EnquiryForm.GetIBasicEnquiryControl2(
            "cmbAssocType",EnquiryControlMissing.****.AssocHeading = Convert.ToString(
            EnquiryForm.GetIBasicEnquiryControl2("txtAssociateHeading").Value);
            
        ****.Update();
    }
    
    FWBS.OMS.UI.Windows.MessageBox.ShowInformation(“Import Completed”);
}

I have included the sample as an attachment I hope this help

Regards Danny
____________________________________________________________________________________________________________________________
Hi Daniel
Thanks for this. We have installed the package and added the form. We have modified the query in the data list so all good. The only issue is that the 'Add to File Button' attempts to open a new file by loading the file select wizard, rather than just associating the selected contacts with the file already open. Many thanks
____________________________________________________________________________________________________________________________
Hi

No problems.Simply change this line
Code:

FWBS.OMS.OMSFile file = FWBS.OMS.UI.Windows.Services.SelectFile();
to
Code:

FWBS.OMS.OMSFile file = Enquiry.Object as FWBS.OMS.OMSFile;
____________________________________________________________________________________________________________________________
Hi

This is assuming you registered my sample as OMS Object against a File object in the designer and you will have to change the DataBuilder source type to Object and Source to Parameter to BoundValue to %FILEID%. if not then change the line to
Code:

FWBS.OMS.OMSFile file = Enquiry.Parent as FWBS.OMS.OMSFile;
Regards
Danny
____________________________________________________________________________________________________________________________
Thanks Daniel - that worked a treat. Hopefully others will find this as useful as we will. Thanks again.
Back to top
Permissions in this forum:
You cannot reply to topics in this forum