EricoDellaVallePrezzi76043714

Repository Auto-selection based on the logged user machine

Discussion created by EricoDellaVallePrezzi76043714 on Dec 2, 2015
Latest reply on Dec 4, 2015 by Chris_Hackett

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.

Outcomes