<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Control&#x2F;display operations via script]]></title><description><![CDATA[<h4>To list operations on Dashboard.</h4>
<h5>Script: <code>JavaScript</code></h5>
<pre><code>var myImports = new JavaImporter(java.io, java.lang, java.util);

with(myImports) {
  var filters = new HashMap();
  filters.put("orderBy", "name");
  filters.put("order", "asc");
  filters.put("pageLimit", new Long(10));
  //Get operations data
  var operations = mcApi.operation().getAll(filters);
}
</code></pre>
<h5>Template:</h5>
<pre><code>&lt;table class="table table-hover table-bordered table-striped mc-table"&gt;
  &lt;thead&gt;
    &lt;th&gt;{{ 'STATUS' | translate }}&lt;/th&gt;
    &lt;th&gt;{{ 'ID' | translate }}&lt;/th&gt;
    &lt;th&gt;{{ 'NAME' | translate }}&lt;/th&gt;
    &lt;th&gt;{{ 'OPERATION' | translate }}&lt;/th&gt;
    &lt;th&gt;{{ 'LAST_EXECUTION' | translate }}&lt;/th&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;#list operations.data as item&gt;
      &lt;tr ui-sref="operationsAddEdit({id: ${item.id} })"&gt;
        &lt;td class="text-center"&gt;
          &lt;#if item.enabled&gt;
            &lt;i class="text-success fa fa-circle fa-lg" uib-tooltip="{{ 'ENABLED' | translate }}"&gt;&lt;/i&gt;
          &lt;#else&gt;
            &lt;i class="text-danger fa fa-circle-o fa-lg" uib-tooltip="{{ 'DISABLED' | translate }}"&gt;&lt;/i&gt;
          &lt;/#if&gt;
        &lt;/td&gt;
        &lt;td&gt;${item.id}&lt;/td&gt;
        &lt;td&gt;${(item.name)!}&lt;/td&gt;
        &lt;td ng-bind-html="'${(item.operationString)!}' | mcResourceRepresentation"&gt;&lt;/td&gt;
        &lt;td&gt;&lt;span uib-tooltip="{{ ${(item.lastExecution?c)!"Never"} | date:mchelper.cfg.dateFormat:mchelper.cfg.timezone}}" tooltip-placement="left" am-time-ago="${(item.lastExecution?c)!"Never"}"&gt;&lt;/span&gt;&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/#list&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
</code></pre>
<h4>To enable/disable list of operations:</h4>
<h5>JavaScript</h5>
<p dir="auto"><strong>Script bindings:</strong> <code>{options:{name:"operation-name", enable:false}}</code><br />
<strong>Important</strong>: It is important to pass <code>Script bindings</code> when executing this script. In the binding you can include your operation <code>name</code> to filter. Please note in Mycontroller all filters are working with case sensitive. In the name filed you can put any words where operation name contains.</p>
<p dir="auto">For example I want to enable or disable following operations,</p>
<ul>
<li><code>my send email notification operation</code></li>
<li><code>notification: pushbullet</code></li>
</ul>
<p dir="auto">In the above names I have <code>notification</code> word in common. So I can use this name in filter to get these operations exactly.</p>
<h6>To disable:</h6>
<p dir="auto"><code>{options:{name:"notification", enable:false}}</code></p>
<h6>To enable:</h6>
<p dir="auto"><code>{options:{name:"notification", enable:true}}</code></p>
<pre><code>var myImports = new JavaImporter(java.io, java.lang, java.util);

with(myImports) {
  var filters = new HashMap();
  var names = new ArrayList();
  names.add(options.name);

  filters.put("orderBy", "name");
  filters.put("order", "asc");
  filters.put("pageLimit", new Long(10));
  filters.put("name", names)

  //Get operations data
  var operations = mcApi.operation().getAll(filters);
  
  var operationIds = new ArrayList();
  for(var count =0 ; count&lt;operations.data.length;count++){
    //You can do some filter here
     operationIds.add(operations.data[count].id);
  }
  
  if(options.enable){
   mcApi.operation().enableIds(operationIds);
  }else{
   mcApi.operation().disableIds(operationIds);
  }
}
</code></pre>
<p dir="auto"><strong>SOURCE:</strong> refer <a href="https://github.com/mycontroller-org/mycontroller/issues/235" rel="nofollow ugc">this issue</a> for complete details.</p>
]]></description><link>http://forum.mycontroller.org/topic/46/control-display-operations-via-script</link><generator>RSS for Node</generator><lastBuildDate>Fri, 15 May 2026 01:30:26 GMT</lastBuildDate><atom:link href="http://forum.mycontroller.org/topic/46.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 31 Aug 2016 18:25:18 GMT</pubDate><ttl>60</ttl></channel></rss>