Columns from extra tables in archive providers

lock
push_pin
done
Answered
4

I'm trying to fetch a list of contacts using the SuperOffice.WebApi C# library, and I want to include some attributes from an extra table y_whatever/x_name.

The table has a key x_contact defined as a relation to the contact entity.  I tried

var result = await agent.GetArchiveListByColumns2Async(
                "Contact",
                "contactUdef/My:SpecialID, name, registeredDate, contactExtra/y_whatever/x_name",
                "name",
                restrictions.ToString(),
                "contact",
                0,
                10
            );

The result contains data for all but the last column.

There is probably a way to retrieve extra data that I'm just too inexperienced to find.  Please help?

Bonus question: While I have been testing fetching a simple text field from the extra table, the data I really want is defined in another extra table, call it y_codeTable.  The y_whatever table is defined with an "Extra table relation" field to this.  How can I follow that relation to find y_codeTable/x_description?

10 Apr 2024 | 08:40 AM

All Replies (4)

Hi Peder,

Try retrieving the available columns using the .GetAvailableColumnsAsync("contact", "") method. Specifically the Name property of the ArchiveColumnInfo.

That way you can figure out the correct column name for the fields you want to query.

12 Apr 2024 | 02:10 PM
Excellent! Thank you, problem solved.
18 Apr 2024 | 10:20 AM

Hello Peder, 

Expanding on @David suggestion i set up a couple of tables and tried to recreate what i THINK is your setup (?):
1. y_whatever has a relation-field to contact
2. y_whatever has a relation-field to y_codetable
3. y_codetable has a field x_description

If i understand your case correctly you are actually after the x_description, and the structure above is how you have set up the relation between the tables.

This is how you could go about fetching the data from the structure above: 

    var columns = await archiveAgent.GetAvailableColumnsAsync("Contact", "");
    foreach( var column in columns )
    {
        if(column.Name.Contains("contactExtra"))
            Console.WriteLine(column.Name);
        /* This is what the console logs in my scenario
         * contactExtra/y_whatever/x_contact_id/id
         * contactExtra/y_whatever/x_contact_id/x_codetable_id
         * contactExtra/y_whatever/x_contact_id/x_codetable/id
         * contactExtra/y_whatever/x_contact_id/x_codetable/x_code
         * contactExtra/y_whatever/x_contact_id/x_codetable/x_description
         * 
        */
    }

    // And i add all these fields to the columns of my request
    var result = await archiveAgent.GetArchiveListByColumns2Async(
    "Contact",
    "name, contactExtra/y_whatever/x_contact_id/id, contactExtra/y_whatever/x_contact_id/x_codetable_id, contactExtra/y_whatever/x_contact_id/x_codetable/id, contactExtra/y_whatever/x_contact_id/x_codetable/x_code, contactExtra/y_whatever/x_contact_id/x_codetable/x_description",
    "name",
    "contactId eq 4",
    "contact",
    0,
    10
);

Note that the fullName of the field, for example 'contactExtra/y_whatever/x_contact_id/x_codetable/x_description', does not have to be equal in your system, as that is up to how you have defined the fields and tables. I therefore suggest you do as David said, and check what the fieldnames actually are in your system (I do the same in the example above).

Also note that for the fields in the x_codetable to show up in the archive you have to check this box where you define the extratable relation:


For future reference I also suggest reading this discussion, which has some insightful information pertaining to extra table queries using the dynamic archive provider: 

https://community.superoffice.com/en/technical/forums/api-forums/online-web-services/performance-in-rest-api---/



Have a SUPER day!


//Eivind

16 Apr 2024 | 08:47 AM
Thank you. Lot's of useful information here. It turns out my first attempt had missed that I needed the x_contact_id as part of the path. After looking at the available columns, it was a trivial fix.
18 Apr 2024 | 10:21 AM

Add reply