1 Reply Latest reply on Feb 17, 2016 4:26 AM by Markus.Gonser

    Set Personal Self-Service Dashboard for role via script

    Expert

      Hi,

       

      I've downloaded the relevant script to do this - but it's not updating the personal self-service dashboard for the specified role.

      I've tried removing the ui_client_type condition as most of our relevant dashboards don't match this..

      Also tried changing  'WebAccess.DefaultDashboard' to 'WebAccess.SelfServiceDefaultDashboard'..

      Not getting any errors, and rows are being updated, but dashboard not changing

      We are on v2016...

      Any ideas?

      Thanks - Adam.

       

      declare @DashboardName nvarchar(200)
      declare @UserType nvarchar(200)
      declare @UserRole nvarchar(200)
      set @DashboardName = 'Basic Support SelfService' -- Replace with the name of the dashboard to use.
      set @UserType = 'Analyst' -- Replace with the user type to set the default dashboard for.
      set @UserRole = 'Basic Users' -- Replace with NAME value for ROLE.

      --- do not modify below this line ---

      declare @DashboardGuid uniqueidentifier
      declare @UserTypeGuid uniqueidentifier
      declare @RoleGuid uniqueidentifier
      select @DashboardGuid = ui_guid from ui_dashboard where ui_title = @DashboardName and ui_client_type = 5
      select @UserTypeGuid = tps_guid from tps_user_type where tps_name = @UserType
      select @RoleGuid = tps_guid from tps_role where tps_name = @UserRole
      if @DashboardGuid is null or @UserTypeGuid is null or @RoleGuid is null
      begin
      print 'Error: Cannot find dashboard, user type or role'
      return
      end
      declare @PreferenceGuid uniqueidentifier
      select @PreferenceGuid = tps_guid from tps_system_preference where tps_fullname = 'WebAccess.DefaultDashboard'

      -- update existing personal default dashboard records
      update tps_user_preference set tps_value = lower(@DashboardGuid)
      where tps_system_preference_guid = @PreferenceGuid
      and tps_user_guid in (select tps_guid from tps_user where tps_user_type_guid = @UserTypeGuid)
      and tps_user_guid in (select tps_user_id from tps_user_role where tps_role_id = @RoleGuid)

      -- add personal default dashboard records for remaining users
      insert into tps_user_preference (tps_guid, tps_user_guid, tps_system_preference_guid, tps_value)
      (select NEWID(), tps_guid, @PreferenceGuid, lower(@DashboardGuid) from tps_user
      join tps_user_role on tps_user_role.tps_user_id=tps_user.tps_guid
        where tps_user_type_guid = @UserTypeGuid and tps_deleted = 0
         and tps_user_role.tps_role_id = @RoleGuid and tps_deleted = 0
        and tps_guid not in (select tps_user_guid from tps_user_preference where tps_system_preference_guid = @PreferenceGuid))

        • 1. Re: Set Personal Self-Service Dashboard for role via script
          Markus.Gonser ITSMMVPGroup

          Hi Adam,

           

          I´ve checked your scipt and found that you have insert the title of your olre and your dashboard but you have to insert the name-attribute. (no blanks)

           

          set @DashboardName = 'Basic Support SelfService'  'BasicSupportSelfService' -- Replace with the name of the dashboard to use.

          set @UserType = 'Analyst' -- Replace with the user type to set the default dashboard for.

          set @UserRole = 'Basic Users' 'BasicUsers' -- Replace with NAME value for ROLE.

           

          Please test this.


          best regards

          Markus