代码之家  ›  专栏  ›  技术社区  ›  Azoulay Jason

如何从模块获取所有记录-SugarCRM版本7+

  •  2
  • Azoulay Jason  · 技术社区  · 8 年前

    根据 documentation ,若要查询记录,必须使用此终结点 /<module>/:recordId 但是如果我想从一个给定的模块中获取所有记录怎么办?我找不到这方面的任何文件。

    我试过了 /<module>/filter 要设置这样的JSON参数:

    {
        "max-num": "-1",
        "offset": "0",
        "order-by": "date-entered",
        "favorites": false,
        "my-items": false
    }
    

    但只返回20条记录?

    当然我试着定制 "max-num" 有大量的数字,但仍然返回20条记录。

    我需要帮助

    1 回复  |  直到 8 年前
        1
  •  1
  •   Jay    8 年前

    max_num max-num

    最大值 $sugar_config['max_record_fetch_size']

    next_offset -1 在这种情况下,您应该发送另一个请求 的值为 offset

    笔记

    • fields
    • 设置 也会影响列表视图中“全选”的记录数。

    0 ,这是第一个可用的记录:

    {
        offset: 0,
        max_num: 1000
    }
    

                                 {
                                     next_offset: 1000,
                                     records: [array of 1000 records]
                                 }
    

    我们收到前1000条记录(偏移0到999) ,我们做的第一个记录的偏移量 1000 如中所述

    {
        offset: 1000,
        max_num: 1000
    }
    

                                 {
                                     next_offset: 2000,
                                     records: [array of 1000 records]
                                 }
    

    响应2 2000 如中所述

    {
        offset: 2000,
        max_num: 1000
    }
    

    响应3

                                 {
                                     next_offset: -1,
                                     records: [array of 341 records]
                                 }
    

    具有 这意味着我们现在已经收到了所有1000+1000+341=2341条可用记录。

     ______________________________
    |                              |  \                  \
    |                              |   |                  \
    |         "Page 1"             |   |__ 1000 records    |
    | records at offset     0..999 |   |                   |
    |                              |   |                   |
    |______________________________|  /                    |
    |                              |  \                    |
    |                              |   |                   |__ all 2341 records
    |         "Page 2"             |   |__ 1000 records    |
    | records at offset 1000..1999 |   |                   |
    |                              |   |                   |
    |______________________________|  /                    |
    |                              |  \                    |
    |         "Page 3"             |   |__  341 records    |
    | records at offset 2000..2340 |   |                  /
    |______________________________|  /                  /