- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2024 01:53 PM
I just created a record producer that will generate an Idea but want to change the button in order to do so:
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2024 09:23 PM
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
    }
})();
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2024 09:23 PM
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
    }
})();
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
