Clarity Service Management

Expand all | Collapse all

Repository Auto-selection based on the logged user machine

  • 1.  Repository Auto-selection based on the logged user machine

    Posted 12-02-2015 12:17 PM

    On our environment (SDM 14.1 advanced availability), repository daemons cannot comunicate between different application servers, due to network/DNS issues.

     

    Our solution was to customize SDM attachment forms to auto-select the repository based on the logged user machine.

    These are the following adaptations made:

     

    1) Include a string field on the doc_rep table through Schema_Designer

    schema_designer.jpg

    2) Add the following code on attmnt_upload_popup.htmpl:

    This is supposed to get the repository persid based on the logged user machine and pass it to LoadUploadActions function, called on the body tag of the form.

    We also made a function to block repository select field via javascript.

    var reps_encontrados = new Array(); 
    <PDM_LIST PREFIX=repositorios FACTORY=doc_rep  WHERE="znomeservidor='${MachineName}'"> 
         reps_encontrados[reps_encontrados.length]='$repositorios.persistent_id'; 
    </PDM_LIST>
    if(reps_encontrados.length == 1) 
    { 
         repID = reps_encontrados[0]; 
    }
    
    function inibeCampoRepositorio()
    {
      document.forms["frmUpload"].elements["inpDocRepository"].disabled = true;
    }
    
    <body onload="LoadUploadActions(repID);inibeCampoRepositorio()" topmargin=0 class="detailro>
    

     

    3) Customize LoadUploadActions function on attmnt_upload.js

    function LoadUploadActions(repID)
    {
      // get the background if in AA mode
      getBGServer();
    
      if(nAttmntId == "undefined" || nAttmntId == "")
      nAttmntId = "0";
      if(typeof propFolderId == "undefined" || propFolderId == "" || isNaN(propFolderId))
      nFolderId = 0;
      else
      nFolderId = propFolderId;
    
      if(nFolderId == 0)
      {
      if( propFolderId  == "SubmitKnowledge")
      targetFolder = 1;
      else if( propFolderId  == "QuickUpload")
      targetFolder = 2;
      else if( propFolderId  == "KnowledgeFiles")
      targetFolder = 3;
      else if( propFolderId  == "QnA")
      targetFolder = 4;
      }
    
    
        if (ahdframeset.name != "AHDtop" && 
      parent.opener.ahdframe != null &&
      typeof parent.opener.ahdframe.argTenantId == "string" && 
      parent.opener.ahdframe.argTenantId != "" ) 
                propTenant = parent.opener.ahdframe.argTenantId;
    
    
        if(propRepId == "" || propRepId == "0")
      propRepId = GetDefaultRepository(propRepType, propTenant);      
      if(propShowRepList == "Yes") // Show the repositories list
      {
      propRepId = loadRepCombo(propRepType, repID, propTenant); // load rep list
      }
    
      UpdateRepInfo(repID);
    

     

    4)Publish schema, forms and clear browser cache to refresh js functionality

     

    5) Add the name of the server (in capital letters) to the field created in step 1 to each repository created

    Add  <PDM_MACRO name=dtlTextbox hdr="Nome do Servidor" attr=znomeservidor rows=1> to detail_doc_rep.htmpl;

    Edit repositories to include the information;

     

    Now, everytime we try attaching a file to a ticket, it auto-selects our repository based on the machine we are logged on.



  • 2.  Re: Repository Auto-selection based on the logged user machine

    Posted 12-02-2015 12:55 PM

    This is really neat information, thanks for sharing it. I see this was posted as a "Question" did you have a particular question, or was this posted to share the information alone?



  • 3.  Re: Repository Auto-selection based on the logged user machine

    Posted 12-02-2015 01:05 PM

    My mistake. I wanted only to share information.

     

    I am new to the community. Next time I'm choosing document or Information categories.



  • 4.  Re: Repository Auto-selection based on the logged user machine

    Posted 12-04-2015 04:45 PM

    Thanks for sharing this with the community Erico!

    Erico Della Valle Prezzi wrote:

     

    On our environment (SDM 14.1 advanced availability), repository daemons cannot comunicate between different application servers, due to network/DNS issues.

     

    Our solution was to customize SDM attachment forms to auto-select the repository based on the logged user machine.

    These are the following adaptations made:

     

    1) Include a string field on the doc_rep table through Schema_Designer

    schema_designer.jpg

    2) Add the following code on attmnt_upload_popup.htmpl:

    This is supposed to get the repository persid based on the logged user machine and pass it to LoadUploadActions function, called on the body tag of the form.

    We also made a function to block repository select field via javascript.

    1. var reps_encontrados = new Array();  
    2. <PDM_LIST PREFIX=repositorios FACTORY=doc_rep  WHERE="znomeservidor='${MachineName}'">  
    3.      reps_encontrados[reps_encontrados.length]='$repositorios.persistent_id';  
    4. </PDM_LIST> 
    5. if(reps_encontrados.length == 1)  
    6. {  
    7.      repID = reps_encontrados[0];  
    8.  
    9. function inibeCampoRepositorio() 
    10.   document.forms["frmUpload"].elements["inpDocRepository"].disabled = true
    11.  
    12. <body onload="LoadUploadActions(repID);inibeCampoRepositorio()" topmargin=0 class="detailro> 

     

    3) Customize LoadUploadActions function on attmnt_upload.js

    1. function LoadUploadActions(repID) 
    2.   // get the background if in AA mode 
    3.   getBGServer(); 
    4.  
    5.   if(nAttmntId == "undefined" || nAttmntId == ""
    6.   nAttmntId = "0"
    7.   if(typeof propFolderId == "undefined" || propFolderId == "" || isNaN(propFolderId)) 
    8.   nFolderId = 0
    9.   else 
    10.   nFolderId = propFolderId; 
    11.  
    12.   if(nFolderId == 0
    13.   { 
    14.   if( propFolderId  == "SubmitKnowledge"
    15.   targetFolder = 1
    16.   else if( propFolderId  == "QuickUpload"
    17.   targetFolder = 2
    18.   else if( propFolderId  == "KnowledgeFiles"
    19.   targetFolder = 3
    20.   else if( propFolderId  == "QnA"
    21.   targetFolder = 4
    22.   } 
    23.  
    24.  
    25.     if (ahdframeset.name != "AHDtop" &&  
    26.   parent.opener.ahdframe != null && 
    27.   typeof parent.opener.ahdframe.argTenantId == "string" &&  
    28.   parent.opener.ahdframe.argTenantId != "" )  
    29.             propTenant = parent.opener.ahdframe.argTenantId; 
    30.  
    31.  
    32.     if(propRepId == "" || propRepId == "0"
    33.   propRepId = GetDefaultRepository(propRepType, propTenant);       
    34.   if(propShowRepList == "Yes") // Show the repositories list 
    35.   { 
    36.   propRepId = loadRepCombo(propRepType, repID, propTenant); // load rep list 
    37.   } 
    38.  
    39.   UpdateRepInfo(repID); 

     

    4)Publish schema, forms and clear browser cache to refresh js functionality

     

    5) Add the name of the server (in capital letters) to the field created in step 1 to each repository created

    Add  <PDM_MACRO name=dtlTextbox hdr="Nome do Servidor" attr=znomeservidor rows=1> to detail_doc_rep.htmpl;

    Edit repositories to include the information;

     

    Now, everytime we try attaching a file to a ticket, it auto-selects our repository based on the machine we are logged on.