Get a user stamp for approvals

DeepakK
edited April 2023 in User Experience

Hello Anaplanners,

I have a dashboard that allows users to approve or reject requests. I would like the User name to be stamped somewhere (probably a line item) once they choose to approve / reject.

Example: Cost Center 100 is requesting 1 more Employee for Job: Developer. It needs approval from Manager, HR, and Finance. As each of them click the box, I want the specific user to be stamped and also be visible in UX.

Any suggestions?

Best Answer

  • rishi8118
    Answer ✓

    To get the date there are many process mentioned in the site below.

    For user id you could use the below code.

    import requests

    # Set the Anaplan API credentials and endpoint
    base_url = "https://api.anaplan.com"
    workspace_id = "Your Anaplan Workspace ID"
    model_id = "Your Anaplan Model ID"
    user_name = "Your Anaplan User Name"
    password = "Your Anaplan Password"

    # Authenticate and get an access token
    auth_url = f"{base_url}/auth/oauth/token"
    auth_payload = {
        "grant_type": "password",
        "username": user_name,
        "password": password
    }
    auth_response = requests.post(auth_url, data=auth_payload)
    access_token = auth_response.json()["access_token"]

    # Make a GET request to the Users API endpoint
    users_url = f"{base_url}/1/3/workspaces/{workspace_id}/models/{model_id}/users"
    headers = {
        "Authorization": f"AnaplanAuthToken {access_token}"
    }
    response = requests.get(users_url, headers=headers)

    # Extract the user ID from the response
    users = response.json()["users"]
    user_id = None
    for user in users:
        if user["name"] == user_name:
            user_id = user["id"]
            break

    print(f"The user ID is {user_id}")

    for getting other id's required in the code, you can refer to the

Answers