How to get all the lists when using WebApi.Agents (person, sales, Appointment, etc)?

Hi All,

- Testing Resource : SuperOffice.WebApi.Samples

- Using : WebApi.Agents (person, sales, Appointment, etc)

-  sysUserTicket and Agent (person, sales, Appointment, etc.. )

 

How to get all the lists?


- It is no problem to get any each person, sales, and appointment information. - Success

- But I couldn't find how to fetch all person List, sales list, appointment list
  : It can only call primary-keys that are already in the array. Here, how do you get the whole list? 

For example)

====== Begin ==========================================

var appointmentAgent = new PersonAgent(config);

int[] marks = new int[5] { 99, 98, 92, 97, 95 }; <--- how to get the whole list sorted by laster

return await appointmentAgent.GetPersonListAsync(marks);

====== End =========================================

Thanks

RE: How to get all the lists when using WebApi.Agents (person, sales, Appointment, etc)?

Lists are fetched from the Lists agent, but you are looking for lists of the main entities

There you need to use the MDO Agent

If you want to do complex searches you need to use the Archive Agent.

By: Christian Mogensen 18 Oct 2021

RE: How to get all the lists when using WebApi.Agents (person, sales, Appointment, etc)?

Hi Chul,

Because you are using the SuperOffice.WebApi package, you can get all lists using the "lists" list name, and use the returned MDOList item Type property to fetch all list items for each list. 

Here is an example:

var tenantStatus = GetTenantStatus(tenant);
if (tenantStatus.IsRunning)
{
    var sysUserInfo = GetSystemUserInfo();
    var sysUserTicket = await GetSystemUserTicket(sysUserInfo);

    var config = new WebApiOptions(tenant.WebApiUrl);
    config.Authorization = new AuthorizationSystemUserTicket(sysUserInfo, sysUserTicket);

    //config.LanguageCode = "en";
    //config.CultureCode = "en";
    //config.TimeZone = "UTC";

    var mdoAgent = new MDOAgent(config);
    var allLists = mdoAgent.GetSimpleListAsync("lists").Result;

    foreach (var list in allLists)
    {
        // if it's a user-defined list, you have to add the id as suffix...

        if (list.Type.Equals("udlist", StringComparison.OrdinalIgnoreCase))
        {
            list.Type = string.Concat(list.Type, list.Id);
        }

        // get the list by type, because name can be a multi-lingual string.
        // to get language specific names, set the config.LanguageCode and config.Culture

        var listItems = mdoAgent.GetSelectableListAsync(list.Type, true, "", false).Result;
        Console.WriteLine($"List name: {list.Name}, items: {string.Join(", ", listItems.Select(i => i.Name).ToArray())}");
    }
}

Hope this helps!

By: Tony Yates 19 Oct 2021

RE: How to get all the lists when using WebApi.Agents (person, sales, Appointment, etc)?

Hi Tony Yates, It's great! working perfect for me. Thanks million :)

 

By: Chul So 19 Oct 2021