Skip to content

filterArray not working as expected in jotformAPIClient.get_form_submissions() #27

Description

@ehawman-rosenberg

jotformAPIClient.get_form_submissions() isn't using filterArray in a way in keeping with the docs. (also said docs incorrectly reference filter and orderby, instead of filterArray and order_by)


def get_submissions(api_key, set_form_ID, set_limit=100, set_debug=False):
    jotformAPIClient = jf.JotformAPIClient(api_key, debug=set_debug)
    return jotformAPIClient.get_form_submissions(
        formID=set_form_ID,
        limit=set_limit,
        # filterArray={
        #     "workflowStatus:eq":"In Progress",
        # },
        # order_by="created_at"
    )

Result: The 100 most recent submissions.


def get_submissions(api_key, set_form_ID, set_limit=100, set_debug=False):
    jotformAPIClient = jf.JotformAPIClient(api_key, debug=set_debug)
    return jotformAPIClient.get_form_submissions(
        formID=set_form_ID,
        limit=set_limit,
        filterArray={
            "workflowStatus:eq":"In Progress",
        },
        order_by="created_at"
    )

Result: None.


def get_submissions(api_key, set_form_ID, set_limit=100, set_debug=False):
    jotformAPIClient = jf.JotformAPIClient(api_key, debug=set_debug)
    return jotformAPIClient.get_form_submissions(
        formID=set_form_ID,
        limit=set_limit,
        filterArray={
            "workflowStatus:eq":"Approve",
        },
        order_by="created_at"
    )

Result: The oldest 25 results in the "Approved" workflowStatus. (Note the difference in workflowStatus name. Is there some hidden naming going on behind the scenes?)


def get_submissions(api_key, set_form_ID, set_limit=100, set_debug=False):
    # jotformAPIClient = jf.JotformAPIClient(api_key, debug=set_debug)
    # return jotformAPIClient.get_form_submissions(
    #     formID=set_form_ID,
    #     limit=set_limit,
    #     filterArray={
    #         "workflowStatus:eq":"In Progress",
    #     },
    #     order_by="created_at"
    # )
    url = f"https://api.jotform.com/form/{set_form_ID}/submissions?apiKey={api_key}&orderby[created_at]=desc&filter=\u007b%27workflowStatus:eq%27:%27In%20Progress%27\u007d&limit={set_limit}"
    req = urllib.request.Request(
        url,
        data=None,
        # headers are required to avoid a 403
        headers={
            "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36"
        },
    )
    data_json = json.loads(urllib.request.urlopen(req).read())
    return data_json["content"]

Result: The 100 most recent submissions in the "In Progress" workflowStatus. (The desired outcome)
EDIT: jokes, I just realized it's just the most recent submissions. sigh


Please reference this support ticket. The form I am working with is 220114796842154. https://www.jotform.com/answers/4751245-jotform-api-applying-filter-does-not-return-all-submissions/

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions