cancel
Showing results for 
Search instead for 
Did you mean: 

Hack New Record link - create new record of specific type

MarkusBaehr
Contributor III

Here is our use case:

In many of our applications users have to select a type first to proceed with the next step. It would be helpful to provide links to create a new record for each type, e.g. Create new task, create new defect, etc. without using a separate application for each type.

 

I am wondering if the New Record link can be modified to do this. Here is the URL behind the New Record link:

<archer-server>/RSAarcher/GenericContent/Record.aspx?id=0&moduleId=123

 

Does anyone know if there is a possibility to add a parameter to the above link in order to set a specific values list value?

 

Maybe something similar like with the navigation menu filters:

/RSAarcher/SearchContent/Search.aspx?View=Filter&fieldId=16721&filterType=ValueList&filterValues=82833&moduleId=438&formatType=ColumnFlat&reportId=5434&isNavMenuReport=true

 

I tried to combine both links without success.

 

Thanks,

Markus

1 ACCEPTED SOLUTION

Accepted Solutions

DavidPetty
Archer Employee
Archer Employee

Markus the application doesn't understand the added attributes to the URL and parse them.

 

But what you can do this with a custom object, added below.

 

fieldId is the field id of the values list you want to change.

paramName is the attribute (query string) in the URL the custom object will look for.

 

The value of the paramName would be the value id you're going to set the values list to.

 

So the URL to a new record would look like this (sans changing the moduleId),

https://baseurl/RSAArcher/GenericContent/Record.aspx?id=0&moduleId=75&requestType=71531

 

So the custom object is looking for the 'requestType' (base on the value of the paramName variable) in the URL and taking the value, 71531 and using it to set a values list in the record.

 

<script type="text/javascript">
     var queryParameters = null;
     var fieldId = 19810;
     var paramName = "requestType";

     $(document).ready(function () {
          if (getParameterByName(paramName) != '' && getRecordId() == 0) {
               setTimeout(function() { // making IE happy (and sometimes Safari)
                    var valueArray = new Array(1);
                    valueArray[0] = getParameterByName(paramName);
                    ArcherTech.UI.GenericContent.GetInstance().setFieldValue(fieldId, valueArray, '');
               }, 500);
          }
     });

     function getParameterByName(name) {
          name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
          var regexS = "[\\?&]" + name + "=([^&#]*)";
          var regex = new RegExp(regexS);
          var results = regex.exec(window.location.href);
          if(results == null)
               return "";
          else
               return decodeURIComponent(results[1].replace(/\+/g, " "));
     }
</script>
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 Advisory Consultant - Archer, an RSA Business

View solution in original post

6 REPLIES 6

DavidPetty
Archer Employee
Archer Employee

Markus the application doesn't understand the added attributes to the URL and parse them.

 

But what you can do this with a custom object, added below.

 

fieldId is the field id of the values list you want to change.

paramName is the attribute (query string) in the URL the custom object will look for.

 

The value of the paramName would be the value id you're going to set the values list to.

 

So the URL to a new record would look like this (sans changing the moduleId),

https://baseurl/RSAArcher/GenericContent/Record.aspx?id=0&moduleId=75&requestType=71531

 

So the custom object is looking for the 'requestType' (base on the value of the paramName variable) in the URL and taking the value, 71531 and using it to set a values list in the record.

 

<script type="text/javascript">
     var queryParameters = null;
     var fieldId = 19810;
     var paramName = "requestType";

     $(document).ready(function () {
          if (getParameterByName(paramName) != '' && getRecordId() == 0) {
               setTimeout(function() { // making IE happy (and sometimes Safari)
                    var valueArray = new Array(1);
                    valueArray[0] = getParameterByName(paramName);
                    ArcherTech.UI.GenericContent.GetInstance().setFieldValue(fieldId, valueArray, '');
               }, 500);
          }
     });

     function getParameterByName(name) {
          name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
          var regexS = "[\\?&]" + name + "=([^&#]*)";
          var regex = new RegExp(regexS);
          var results = regex.exec(window.location.href);
          if(results == null)
               return "";
          else
               return decodeURIComponent(results[1].replace(/\+/g, " "));
     }
</script>
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 Advisory Consultant - Archer, an RSA Business

David, you are a star! This works like a charm. Thank you!

Dang, David! How much do pants that fancy run a fellow?

 

WELL DONE!

KyleBratton
Contributor III

I could not get this to select the value in 6.4.0.2. Should it work in that version as well? Also, will it work if that field is used to apply conditional layouts based on it's selection?

It should work in all versions Kyle.

 

Yes, it would trigger a rule if the value is changed in this method.  I have one customer that uses it for determining an incident type based on link the user clicks on their intranet site.

 

Above line 24 you can add alert(results); and see what being returned based on the querystring parameter and it's value.

 Advisory Consultant - Archer, an RSA Business

NancyGuhse
Collaborator III

Thank you for sharing this!  This made my week!!     I got this to work in 6.1 P2