Auto add card to every page

Options

Our legal dept. is asking us to add a legal disclaimer to every page in Domo. We have hundreds of pages and this would be a nightmare to manually do and then remember to add each time a new page is added. Anyone know of a way to auto-add a card to the appendix of every dashboard?

If I solved your problem, please select "yes" above

Tagged:

Best Answers

  • ellibot
    ellibot Contributor
    Answer ✓
    Options

    @ColemenWilson There is a command in the Java CLI called 'restore-card' that lets you add a card to any page in Domo. You can probably script it to find new pages created and then add the card legal wants

  • ArborRose
    ArborRose Coach
    edited May 23 Answer ✓
    Options

    You could try something like this in Python…

    Sorry, the code doesn't want to paste into here easily. Adjust code below to what shows above.

    import requests
    Domo API credentials
    client_id = 'your_client_id'
    client_secret = 'your_client_secret'
    access_token_url = 'https://api.domo.com/oauth/token?grant_type=client_credentials&scope=data%20audit%20user%20dashboard'
    api_url_base = 'https://api.domo.com/v1/' Get access token response = requests.get(access_token_url, auth=(client_id, client_secret))
    access_token = response.json()['access_token'] headers = {'Authorization': f'Bearer {access_token}'} Get list of all dashboards dashboards_response = requests.get(api_url_base + 'pages', headers=headers)
    dashboards = dashboards_response.json() Card ID to be added to all dashboards card_id = 'your_card_id' for dashboard in dashboards:
    dashboard_id = dashboard['id']
    # Add card to dashboard
    add_card_url = f'{api_url_base}pages/{dashboard_id}/cards/{card_id}'
    response = requests.post(add_card_url, headers=headers)
    if response.status_code == 200:
    print(f'Successfully added card to dashboard {dashboard_id}')
    else:
    print(f'Failed to add card to dashboard {dashboard_id}: {response.content}')

    If you don't use Python but want to try it, message me directly and I'll explain how you can execute it from a external folder.

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

Answers

  • david_cunningham
    Options

    My first inclination would be to leverage the API. This wouldn't be perfect, but you could have a script that would run daily, iterate through all pages, and check if a particular card id resides on each page. If not, you could copy that card onto that page. This solution wouldn't automatically add the card at page creation, but the delay would be minimal.

    David Cunningham

    ** Was this post helpful? Click Agree 😀, Like 👍️, or Awesome ❤️ below **
    ** Did this solve your problem? Accept it as a solution! ✔️**

  • ellibot
    ellibot Contributor
    Answer ✓
    Options

    @ColemenWilson There is a command in the Java CLI called 'restore-card' that lets you add a card to any page in Domo. You can probably script it to find new pages created and then add the card legal wants

  • ArborRose
    ArborRose Coach
    edited May 23 Answer ✓
    Options

    You could try something like this in Python…

    Sorry, the code doesn't want to paste into here easily. Adjust code below to what shows above.

    import requests
    Domo API credentials
    client_id = 'your_client_id'
    client_secret = 'your_client_secret'
    access_token_url = 'https://api.domo.com/oauth/token?grant_type=client_credentials&scope=data%20audit%20user%20dashboard'
    api_url_base = 'https://api.domo.com/v1/' Get access token response = requests.get(access_token_url, auth=(client_id, client_secret))
    access_token = response.json()['access_token'] headers = {'Authorization': f'Bearer {access_token}'} Get list of all dashboards dashboards_response = requests.get(api_url_base + 'pages', headers=headers)
    dashboards = dashboards_response.json() Card ID to be added to all dashboards card_id = 'your_card_id' for dashboard in dashboards:
    dashboard_id = dashboard['id']
    # Add card to dashboard
    add_card_url = f'{api_url_base}pages/{dashboard_id}/cards/{card_id}'
    response = requests.post(add_card_url, headers=headers)
    if response.status_code == 200:
    print(f'Successfully added card to dashboard {dashboard_id}')
    else:
    print(f'Failed to add card to dashboard {dashboard_id}: {response.content}')

    If you don't use Python but want to try it, message me directly and I'll explain how you can execute it from a external folder.

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **