Question

Need help working with with Script Task in Business Process using ESQ

I am trying to achieve the following database query in ESQ..

SELECT        AU1.Name, AU.Name AS Role

FROM            SysAdminUnitInRole AS UR LEFT OUTER JOIN

                         SysAdminUnit AS AU ON AU.Id = UR.SysAdminUnitRoleId INNER JOIN

                         SysAdminUnit AS AU1 ON AU1.Id = UR.SysAdminUnitId

WHERE        (UR.SysAdminUnitId = 'd3f74364-5ec1-4171-8f0c-160f0ab3a4c')

 

This is what I came up with in script task..

// Get [Id] of contact object.

var contactId = get("ContactIdParameter");

string esqRoles = "";

var esq = new EntitySchemaQuery(UserConnection.EntitySchemaManager, "SysAdminUnitInRole");

// SysAdminUnit schema with join type LEFT OUTER JOIN will be added to query.

esq.addColumn("SysAdminUnit.Name");

// SysAdminUnit schema with join type INNER JOIN will be added to query.

esq.addColumn("=SysAdminUnit.Name");

var esqFilter = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "SysAdminUnitInRole.SysAdminUnitId", contactId);

esq.filters.add("esqFilter", esqFilter);

// Objects, i.e. query results, filtered by the above filter, will be included into this collection.

EntityCollection entities = esq.GetEntityCollection(UserConnection);

if (entities.Count > 0) {

    foreach (var entity in entities)

    {

        esqRoles = esqRoles + " " + entity.GetTypedColumnValue("SysAdminUnit.Name"));

    }

    //Set the rolespParameter with the esqRoles value

    set("RolesParameter", esqRoles.ToString());

}

return true;

 

I get errors publishing the script task in the Business Process. Need help figuring it out if the script take code is right..

 

Thanks in advance!

 

Like 0

Like

3 comments

So where is the screenshot of the errors?

er

Please open the source code of the business process UsrProcess3 and find what's wrong in the record 56. 

http://prntscr.com/j7g2mx

Show all comments