Sunday, August 6, 2017

REST Get Call inside coach view


var restUrl = '/rest/bpm/wle/v1/system/env/variable?processAppAcronym=TSAPP&name=documentType';


dojo.xhrGet({

// The URL to request


url: restUrl,


/ The method that handles the request's successful result

// Handle the response any way you'd like!

load: function(results) {

parser = new DOMParser();

xmlDoc = parser.parseFromString(results,"text/xml");

documentType=xmlDoc.getElementsByTagName("value")[0].childNodes[0].nodeValue ;


}

});

Result you will get as text. If you want json then handleAs : json
for xml handleAs : xml

 

Friday, January 13, 2017

Start BPD Types

1.By running the process
2.By UCA
3.By using REST
4.by startProcessByName
4.By Using


 tw.system.model.findProcessAppByAcronym('').defaultSnapshot.findProcessByName("Manage Project Documents").startNew(inputs);

have to modify this as readable will make when I have time.

Thanks

Monday, October 10, 2016

Compare Two Lists

var jurisdictionMap = {};

tw.local.errorMessage = "";

for (var i = 0; i < tw.local.jurisdictionNVP.listLength; i++) {
    jurisdictionMap[tw.local.jurisdictionNVP[i].name] = tw.local.jurisdictionNVP[i].value;
}

for(var i=0;i< tw.local.clientCashRows.listLength; i++)
{
    var jurisdictionName = tw.local.clientCashRows[i].jurisdiction;
    if(!!jurisdictionName)
    {
         if(!jurisdictionMap[jurisdictionName])
         {
              tw.local.errorMessage += (tw.local.errorMessage ? ", " : "") + jurisdictionName;
              var errorMessage = "Jurisdiction is not present in table Please verify once " + jurisdictionName;
              log4j.error(errorMessage);
         }
    }
}

if (tw.local.errorMessage) {
    tw.local.errorMessage = "The following Jurisdiction are not present in the Jurisdiction Table: " + tw.local.errorMessage;
    tw.local.isError = true;
 }

Tuesday, October 4, 2016

Combine Multiple Statements into one Query(SQL Server)



<# tw.local.parameters = new tw.object.listOf.SQLParameter(); #>

declare @wItemId bigint = ?; <# APCAddSqlParameter(tw.local.parameters, tw.local.wItemId); #>
declare @userName nvarchar(255) = ?; <# APCAddSqlParameter(tw.local.parameters, tw.local.userName); #>
declare @historyLength int = 10;

declare @itemId bigint;
declare @roomId bigint;
declare @homeId bigint;

select top 1
    @itemId = ERP.itemId ,
    @roomId = PRJ.roomId ,
    @homeId = ENG.homeId
from WItem2EntityReportingPeriod WI2ERP
    join EntityReportingPeriod ERP on WI2ERP.entityReportingPeriodId = ERP.entityReportingPeriodId
    join Project PRJ on PRJ.roomId = ERP.roomId
    join Engagement ENG on ENG.engagementId = PRJ.engagementId
where WI2ERP.wItemId = @wItemId ;

update UserActivity
set lastUpdated = CURRENT_TIMESTAMP
where userName = @userName
    and itemId = @itemId
    and roomId = @roomId
    and homeId = @homeId ;

if @@ROWCOUNT = 0
begin
    -- delete old rows for user from UserActivity
    with uaDates as (
        select userActivityId
            , row_number() over (order by lastUpdated desc) as rowNumber
        from UserActivity
        where userName = @userName
    )
    delete UserActivity
    from UserActivity UA
        join uaDates on UA.userActivityId = uaDates.userActivityId
    where uaDates.rowNumber >= @historyLength;

    -- add new UserActivity
    insert into UserActivity (userActivityId, userName, homeId , roomId , itemId , lastUpdated)
    values (next value for UserActivity_Seq, @userName, @homeId , @roomId , @itemId , CURRENT_TIMESTAMP);
end

Thursday, October 1, 2015

Detect and Handle(Terminate) Infinite loop in javascript IBM BPM

Termination of a infinite loop inside a java snippet inside a bpd is possible in 8.5.5 and later versions

Modify 100Custom.xml file of your process center process server installation.
Location:
Network Deployment Cluster - 
                         --> Profile_Root/config/cells/cell_name/clusters/cluster_name/server_type/config/100Custom.xml.

Network Deployment Single Cluster - 
             --> Profile_Root\config\cells\PCCell1\nodes\Node1\servers\server1\process-center\config/100Custom.xml

Update the 100Custom.xml with below xml

<?xml version="1.0" encoding="UTF-8" ?>

<properties>
<common>
   <javascript-engine>
          <loop-detection-duration marge="replace">90</loop-detection-duration/>
          <enable-javascript-execution marge="replace">true</enable-javascript-execution/>
     </javascript-engine>
</common>
</properties>

Restart the server.

verify the configuration
Location:
PROFILE_ROOT\config\cells\PCCell1\nodes\Node1\servers\server1\process-center\TeamWorksConfiguration.running.xml

make sure that settings have made.

This will terminate if any infinite loop found in javascript

I Fixes are avialble for other versions as well

Friday, August 7, 2015

Visibility Inside Coach View

For Coach View components we don't have custom visibility.

 In side Coach visibility options

Inside Coach View visibility options

If we want to add custom visibility inside coach view we don't have default options we have to customize the coach view.

Example Scenario

          we have select and text CV inside coach view. based on selected value we need to show or hide the text coach view.

               

Solution:

1.Get the Vertical Section sub-view inside the change event handler.


                              var n1 = this.context.getSubview("Vertical_Section1", true)[0];
2.Get the selected value of select box and compare with your value.if Selected value is yes the shoe the text CV else Hide the CV.
Write the below code in both view and change.when loading and changing the select box this script will apply.

                var n1 = this.context.getSubview("Vertical_Section1", true)[0];

                  if(this.context.options.seletedItem.get("value").get("name")=="YES")
                 {
                         var n2 = n1.context.getSubview("Text1", true)[0];
                         n2.context.setDisplay(true);
                        n2.context.options._metadata.visibility.set("value","DEFAULT");
                  }
                 if(this.context.options.seletedItem.get("value").get("name")=="NO")
                 {
                         var n2 = n1.context.getSubview("Text1", true)[0];
                         n2.context.setDisplay(false);
                  }



Results:

1. When we select Yes we are showing the text CV.
2.When we select No we are hiding the text CV.



Hope this is useful....................
                 

Wednesday, August 5, 2015

Active Instance List

If you want to get the all the active instances for the specified process application.

this TWSearch will return all the active instances.


var col1 = new TWSearchColumn();
col1.name = TWSearchColumn.ProcessInstanceColumns.ID;
col1.type = TWSearchColumn.Types.ProcessInstance;

var condition = new TWSearchCondition();
condition.column = new TWSearchColumn();
condition.column.name = TWSearchColumn.ProcessInstanceColumns.Status;
condition.column.type = TWSearchColumn.Types.ProcessInstance;
condition.operator = TWSearchCondition.Operations.Equals;
condition.value = "Active";


var condition2 = new TWSearchCondition();
condition2.column = new TWSearchColumn();
condition2.column.name = TWSearchColumn.ProcessColumns.Name;
condition2.column.type = TWSearchColumn.Types.Process;
condition2.operator = TWSearchCondition.Operations.Equals;
condition2.value = "Test";


var search = new TWSearch();
search.columns = [col1];

search.conditions = [condition, condition2];
var order1 = new TWSearchOrdering();
order1.column = col1;
order1.order = TWSearchOrdering.Orders.Descending;
search.orderBy = new Array(order1);
search.organizedBy = TWSearch.OrganizeByTypes.ProcessInstance;
var results = search.execute();
   
var instaceID[];
 for(var i=0;i<results.rows.length;i++)
        {
                  instaceID[] =  results.rows[i].values[0];

     }