Home Analyst Portal

Custom DataSource variable

Magnus_Lundgren1Magnus_Lundgren1 Customer Adept IT Monkey ✭✭
edited April 2018 in Analyst Portal
Hi.

I have created my own get userinfo query, i basically gets everything that GetUserRelatedInfoByUserId gets.
The problem with my enviroment is that it takes up to 10 sec before that API call is finished.
and /Search/GetObjectProperties does not include email
We use it to fill in textprompts with userinfo like Office, departmant, phonenumer etc.

My new query looks like this

USE ServiceManagement

DELETE FROM dbo.DataSource
WHERE Id = '571f324a-c80b-4ac2-a576-a1ffc8bc78d3'

INSERT INTO dbo.DataSource (Id, Title, ConnectionString, Query, DataSourceId)
VALUES ('571f324a-c80b-4ac2-a576-a1ffc8bc78d3', 'UserInfoID', NULL, '

SELECT [Id]
      ,[BusinessPhone]
      ,[Company]
      ,[Country]
      ,[Department]
      ,[DisplayName]
      ,[Domain]
      ,[EmployeeId]
      ,[FirstName]
      ,[LastName]
      ,[Mobile]
      ,[Office]
      ,[Pager]
      ,[UPN]
      ,[OrganizationalUnit]
      ,[SID]
      ,[Title]
      ,[UserName]
      ,[EmailAddress1]
  FROM [ServiceManagement].[dbo].[CI$User]
  Where ID = @UserId', '1');

But i also want a query where i can pass the ID from a query prompt.
like

var divGridControls = $("div[data-control=checkboxGridByCriteriaOld");
var thisKendoGrid = $(divGridControls[4]).getKendoGrid();
var kendoGridIndex = 4;
thisKendoGrid.kendoGridIndex = kendoGridIndex;

thisKendoGrid.bind("change", function (e){
	var thisEventKendoGrid = e.sender;

	var selectedRow = thisEventKendoGrid.select();			
	var uid = thisEventKendoGrid.dataItem(selectedRow).Id;
	
	$.ajax({
		url: '/api/V3/User/GetUserRelatedInfoByUserId',  
		data: {userId: uid},


Can i create a dashboardquery that i can pass the ID from the selected row of a query prompt?



Answers

  • Magnus_Lundgren1Magnus_Lundgren1 Customer Adept IT Monkey ✭✭
    Got my answer from @Martin_Blomgren :smiley: 

    USE ServiceManagement
    
    DELETE FROM dbo.DataSource
    WHERE Id = 'F282CDD2-63BC-4E98-BABC-B1186C4E68A8'
    
    INSERT INTO dbo.DataSource (Id, Title, ConnectionString, Query, DataSourceId)
    VALUES ('F282CDD2-63BC-4E98-BABC-B1186C4E68A8', 'UserQueryInfoID', NULL, '
    DECLARE @UserFromQuery uniqueidentifier = ''{{UserFromQuery}}'';
    SELECT [Id]
          ,[BusinessPhone]
          ,[Company]
          ,[Country]
          ,[Department]
          ,[DisplayName]
          ,[Domain]
          ,[EmployeeId]
          ,[FirstName]
          ,[LastName]
          ,[Mobile]
          ,[Office]
          ,[Pager]
          ,[UPN]
          ,[OrganizationalUnit]
          ,[SID]
          ,[Title]
          ,[UserName]
          ,[EmailAddress1]
      FROM [ServiceManagement].[dbo].[CI$User]
      Where ID = @UserFromQuery', '1');
    Then run for ex

    var divGridControls = $("div[data-control=checkboxGridByCriteriaOld");
    var thisKendoGrid = $(divGridControls[4]).getKendoGrid();
    var kendoGridIndex = 4;
    thisKendoGrid.kendoGridIndex = kendoGridIndex;
    
    thisKendoGrid.bind("change", function (e){
    	var thisEventKendoGrid = e.sender;
    
    	var selectedRow = thisEventKendoGrid.select();			
    	var uid = thisEventKendoGrid.dataItem(selectedRow).Id;
    
    	$.ajax({
            url: "/api/v3/Dashboard/GetDashboardDataById",
    		data: {dateFilterType: "NoFilter", queryId: "f282cdd2-63bc-4e98-babc-b1186c4e68a8", UserFromQuery: uid},
            type: "GET",
            dataType: "json",
            contentType: 'application/json; charset=UTF-8',
            async: false,
    		success:function(data) {
    		var data2 = data[0];
    		
    			var email = data2.Email;	
    			var Telephone = data2.BusinessPhone;
    
    			var textareaId = document.getElementsByTagName("textarea")[8].id;
    			$(document.getElementById(textareaId).value=Telephone);
    			$(document.getElementById(textareaId).onkeyup(this));
    			var textareaId = document.getElementsByTagName("textarea")[7].id;
    			try {
    				$(document.getElementById(textareaId).value=email);
    			} catch(err){}
    			$(document.getElementById(textareaId).onkeyup(this));
    		}
    	});	
    
    });



Sign In or Register to comment.