Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning display values when using get_multiple #174

Open
solexNY opened this issue Apr 19, 2021 · 1 comment
Open

Returning display values when using get_multiple #174

solexNY opened this issue Apr 19, 2021 · 1 comment

Comments

@solexNY
Copy link

solexNY commented Apr 19, 2021

I have a query that returns the display values when using the response.all() function, but I cannot get the display values when using the response.get_multiple() function.

the following does not resolve the display values, any help would be appreciated.

    client = _client()
    
    # to resolved linked table to their display names and not the foreign key
    client.parameters.display_value = True 
    
    # only return these fields
    incident_fields = ['number', 'u_application', 'assigned_to', 'u_department_billing']
    client.parameters.fields = incident_fields

   start_dt = datetime.datetime.strptime(start, '%Y-%m-%d')
    end_dt = datetime.datetime.strptime(end, '%Y-%m-%d')
    
    query = ( snow.QueryBuilder()
        .field('assignment_group').starts_with(assignment_group)
        .AND()
        .field('sys_created_on').between(start_dt,end_dt)
        .AND()
        .field('u_application').is_not_empty()
        .AND()
        .field('assigned_to').is_not_empty()
        .AND()
        .field('u_department_billing').is_not_empty()
    )

    response = client.query('incident', query=query)

    for ticket in response.get_multiple(fields=incident_fields, offset=50, limit=50, order_by=['-sys_created_on']):
        ......

this works


    client = _client()
    
    # to resolved linked table to their display names and not the foreign key
    client.parameters.display_value = True 
    
    # only return these fields
    incident_fields = ['number', 'u_application', 'assigned_to', 'u_department_billing']
    client.parameters.fields = incident_fields

    incident = client.resource(api_path = '/table/incident')
    
    start_dt = datetime.datetime.strptime(start, '%Y-%m-%d')
    end_dt = datetime.datetime.strptime(end, '%Y-%m-%d')
    
    query = ( snow.QueryBuilder()
        .field('assignment_group').starts_with(assignment_group)
        .AND()
        .field('sys_created_on').between(start_dt,end_dt)
        .AND()
        .field('u_application').is_not_empty()
        .AND()
        .field('assigned_to').is_not_empty()
        .AND()
        .field('u_department_billing').is_not_empty()
    )

    response = incident.get(query=query)
    
    del _cache_incident
    _cache_incident = pd.DataFrame()

   for ticket in response.all():
             .........

@solexNY
Copy link
Author

solexNY commented Apr 19, 2021

A little more work and could not determine (a) how to configure get_multiple() to return the display values, it returns only the links to the objects or (b) the all() function return the specified fields, it returns all incident fields.

    # <get_multiple()>
    # >>>>>>>>> Uses the client the return is a request object <<<<<<<<<<
    client.parameters.fields = incident_fields # only return these fields
    response = client.query('incident', query=query)
    for ticket in response.get_multiple(fields=incident_fields, offset=50, limit=50, order_by=['-sys_created_on']):
    ...
    # </get_multiple>

    # <response.all()>
    # >>>>>>>>> Uses the resource object return is a response object <<<<<<<<<<
    incident_res = client.resource(api_path = '/table/incident')
    incident_res.parameters.display_value = True
    incident_res.parameters.fields = incident_fields # only return these fields
    response = incident_res.get(query=query)
    for ticket in response.all():
    ....
    # </response.all()>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant