Changing the "Create An Idea" link to point to Record Producer.

tahnalos
Kilo Sage

I just created a record producer that will generate an Idea but want to change the button in order to do so:

 

tahnalos_0-1722372672316.png

 

I know I have to change the following bit of code as seen in Bold:

 

<div class="ideas-list-filler--wrpr" ng-if="data.moduleExists">
<div class="create-idea-cntr">
<h3 class="idea-creation--title m-t-sm h4">${Have an Idea? Share it!}</h3>
<div class="idea-creation-btn-cntr">
<a class="btn btn-primary" role="button" ng-href="?id=create_edit_idea&sysparm_module_id={{data.moduleId}}" >${Create an Idea}</a>
</div>
</div>
</div>

 

Can someone tell me the exact format I need to do set this up to point to the Record Producer?

1 ACCEPTED SOLUTION

Bhavya11
Kilo Patron

Hi @tahnalos ,

 

can you try something like below

HTML

 

<div class="ideas-list-filler--wrpr" ng-if="data.moduleExists" >
<div class="create-idea-cntr">
<h3 class="idea-creation--title m-t-sm h4">${Have an Idea? Share it!}</h3>
<div class="idea-creation-btn-cntr">
      <button class="btn btn-primary" role="button" ng-click="c.redirectToRecordProducer()">${Create an Idea}</button>
</div>
</div>
</div>

 

 

Server Script:

 

(function() {
    // Fetch the Record Producer sys_id, replace 'record_producer_table' with the actual table name
    var rp = new GlideRecord('sc_cat_item');
    rp.addQuery('name', 'Test idea'); // Add your own condition to fetch the specific Record Producer
    rp.query();
    if (rp.next()) {
        data.recordProducerSysId = rp.sys_id.toString();
    } else {
        data.recordProducerSysId = ''; // Handle the case where the record producer is not found
    }
})();

 

 

Client controller
 

 

api.controller=function($scope, $window) {
  /* widget controller */
  var c = this;

    $scope.c = this;

    this.redirectToRecordProducer = function() {
      var recordProducerSysId = $scope.data.recordProducerSysId;
      if (recordProducerSysId) {
        var url = '?id=sc_cat_item&sys_id=' + recordProducerSysId + '&sysparm_module_id=' + $scope.data.moduleId;
        $window.location.href = url;
      } else {
        console.error('Record Producer sys_id not found');
      }
    };
};

 

 

 

 

Please mark helpful & correct answer if it's really worthy for you.

 

Thanks,

Bk

 

View solution in original post

1 REPLY 1

Bhavya11
Kilo Patron

Hi @tahnalos ,

 

can you try something like below

HTML

 

<div class="ideas-list-filler--wrpr" ng-if="data.moduleExists" >
<div class="create-idea-cntr">
<h3 class="idea-creation--title m-t-sm h4">${Have an Idea? Share it!}</h3>
<div class="idea-creation-btn-cntr">
      <button class="btn btn-primary" role="button" ng-click="c.redirectToRecordProducer()">${Create an Idea}</button>
</div>
</div>
</div>

 

 

Server Script:

 

(function() {
    // Fetch the Record Producer sys_id, replace 'record_producer_table' with the actual table name
    var rp = new GlideRecord('sc_cat_item');
    rp.addQuery('name', 'Test idea'); // Add your own condition to fetch the specific Record Producer
    rp.query();
    if (rp.next()) {
        data.recordProducerSysId = rp.sys_id.toString();
    } else {
        data.recordProducerSysId = ''; // Handle the case where the record producer is not found
    }
})();

 

 

Client controller
 

 

api.controller=function($scope, $window) {
  /* widget controller */
  var c = this;

    $scope.c = this;

    this.redirectToRecordProducer = function() {
      var recordProducerSysId = $scope.data.recordProducerSysId;
      if (recordProducerSysId) {
        var url = '?id=sc_cat_item&sys_id=' + recordProducerSysId + '&sysparm_module_id=' + $scope.data.moduleId;
        $window.location.href = url;
      } else {
        console.error('Record Producer sys_id not found');
      }
    };
};

 

 

 

 

Please mark helpful & correct answer if it's really worthy for you.

 

Thanks,

Bk