Hello community I'm trying show a Contact.Type in a custom profile. But i have a error when put the diff:

	{
		"operation": "insert",
		"name": "ContactType",
		"values": {
			"layout": {
				"colSpan": 24,
				"rowSpan": 1,
				"column": 0,
				"row": 1,
				"layoutName": "UsrLeftContainer"
			},
			"bindTo": "Contact.Type",
			"enabled": true,
			"contentType": 5
		},
		"parentName": "UsrLeftContainer",
		"propertyName": "items",
		"index": 0
	},

And the console return me:

Heading for label Contact.Type not found.

 

Is something worn in the code?

 

Regards,

 

 

 

Like 0

Like

1 comments

Unfortunately, the out-of-the-box system doesn't allow displaying linked fields. If you want to do this, you need to create a custom control that will process the linked field. If you want only show the value without a modification option, please consider creating a new field linked to an attribute (virtual column). This way you'll need to fill the attribute in with the needed value with a method. Please search the "dependencies" keyword in an out-of-the-box js code for more information. 

Show all comments

Hi community!

How are you?

I hope you can help me with the following

 

I have a query with ESQ on "EmployeeMiniPage" to validate that the "NroLegajo" field in the Employee entity is not repeated. When I apply certain permissions on a record so that only certain users can see it, the query not consider that record when I log in with a user who does not have permissions, and therefore allows me to enter an existing "NroLegajo" that belongs to that record. To solve this I set the "QueryJoinRightLevel" system variable with value "2" (Disabled) but it does not work. 

 

I reassigned and denied permissions on the registry to do the test and when I logged in with the user who does not have permissions on the registry I can continue entering a repeated value in the field "NroLegajo"

Any idea?

Is there an alternative a ESQ?

King Regards,

Ezequiel

Like 1

Like

14 comments

Dear Ezequiel,

In order to omit rights check you can create an ESQ on the server side by the means of C#. However, instead of using UserConnection, you can use SystemUserConnection, which would let you execute the functionality no matter under what user.

"Script task" business process element or service will perfectly fit and cover the task. Choose the means more comfortable for you.

Here is how to obtain SystemUserConnection:

private SystemUserConnection SystemUserConnection {
			get {
				return _systemUserConnection ?? (_systemUserConnection = (SystemUserConnection)AppConnection.SystemUserConnection);
			}

Here is an article of how to build ESQ on server side. Though, its pretty much the same as on the client side:

https://academy.bpmonline.com/documents/technic-sdk/7-11/use-entitysche…

Hope you find it helpful.

Regards,

Anastasia

Hi Anastasia!

Thanks you for your answer!

How could I validate in the Employee registration that the "Legajo" field value is not repeated in the way you are indicating?

 Can I call a business process from EmployeeMiniPage to return an answer?

I need that validation along with others before saving the employee!

King Regards!

Ezequiel

 

Dear Ezequiel,

In order to implement such functionality on the page, you need to do the following;

1. Create a webservice, which brushes through the Employee table for duplicates. Please see more details on how to write a service here:

https://academy.bpmonline.com/documents/technic-sdk/7-8/how-call-config…

2. Create a new virtual boolean attribute. We will use it in our further steps.

            "ESQCompleted": {
                dataValueType: Terrasoft.DataValueType.BOOLEAN,
                type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN
                value: false
            }

3. Override a basic save() method and firstly insert a validation, that if this.get("ESQCompleted") true, than we call parent function, if not, than run service call, as in the article.

4. In the response, based on the result, you either show information dialog regarding existing duplicate, or set attribute to true and call save method again.

Regards, 

Anastasia

Dear Anastasia,

Sorry, for the delay in the response. When working with the service I found several errors, I could not include the SystemUserConnection variable because it was throwing errors and when working with UserConnection as a test I also get several errors. Am i missing a reference?. I attach the code

namespace Terrasoft.Configuration.Test
{
	using System;
	using System.ServiceModel;
	using System.ServiceModel.Web;
	using System.ServiceModel.Activation;
	using System.Collections.Generic;
	using System.Collections.ObjectModel;
	using System.Data;
	using Terrasoft.Common;
	using Terrasoft.Core;
	using Terrasoft.Core.DB;
	using Terrasoft.Core.Entities; 
	// Service class is marked with [ServiceContract] compulsory attributes and
	// [AspNetCompatibilityRequirements] with parameters.
	[ServiceContract]
	[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
	public class EmployeeService
	{
		/*private SystemUserConnection SystemUserConnection {
			get {
				return _systemUserConnection ?? (_systemUserConnection = (SystemUserConnection)AppConnection.SystemUserConnection);
			}
		}*/
		// Service methods are marked with compulsory attributes [OperationContract] and [WebInvoke] with parameters.
		[OperationContract]
		[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, 
			BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
		public string ObtenerCantidadLegajosRepetidos(string nroLegajo, string cuitEmpresa)
		{
			//var result = nroLegajo + " + output string";
			var result = "T";
			entitySchemaManager = UserConnection.EntitySchemaManager;
			var employeeSchema = entitySchemaManager.GetInstanceByName("Employee"); 
			var esqEmployee = new EntitySchemaQuery(entitySchemaManager, employeeSchema.Name);
 
			var colId = esqEmployee.AddColumn("Id");
 
			//Agrego filtros en el query
			var filtroCUIT = esqEmployee.CreateFilterWithParameters(FilterComparisonType.Equal,"Account.UsrCUIT", cuitEmpresa);
			var filtroLegajo = esqEmployee.CreateFilterWithParameters(FilterComparisonType.Equal,"UsrNroLegajo", nroLegajo);
 
 
			// Adding created filters to query collection.
			esqEmployee.Filters.Add(filtroCUIT);
			esqEmployee.Filters.Add(filtroLegajo);
 
			// Execution of cache to database and getting resultant collections of objects.
			// Query results will be placed in cache after completion of this operation.
			var employeeCollection = esqEmployee.GetEntityCollection(UserConnection);
			if (employeeCollection == null || employeeCollection.Count == 0)
			{
				result = "F";
			}
			return result;
		}
	}
}

The errors that appear to me are the following:

I hope you can help me!

King Regards,

Ezequiel

 

Dear Ezequiel,

The reason for an error with UserConnection, is that you are missing "var" in variable declaration:

var entitySchemaManager = UserConnection.EntitySchemaManager;

As for the SystemUserConnection, please add the _systemUserConnection property declaration before the code I have previously indicated, like this: 

private SystemUserConnection _systemUserConnection;
private SystemUserConnection SystemUserConnection {
	get {
	     return _systemUserConnection ?? (_systemUserConnection = 
        (SystemUserConnection)AppConnection.SystemUserConnection);
	}
}

Hope this will solve the issue.

Regards,

Anastasia

Dear Anastasia!

How are you? Thank you for your answer!

Could it be that I'm missing a reference? I attached image

Regards!

Ezequiel

Dear Ezequiel,

Please try to make variable, which you assign SystemUserConnection, of a static type. In case this won't help, please share the whole code.

Regards,

Anastasia

Dear Anastasia,

I continue with the problem. I attached code.

namespace Terrasoft.Configuration.Test
{
	using System;
	using System.ServiceModel;
	using System.ServiceModel.Web;
	using System.ServiceModel.Activation;
	using System.Collections.Generic;
	using System.Collections.ObjectModel;
	using System.Data;
	using Terrasoft.Common;
	using Terrasoft.Core;
	using Terrasoft.Core.DB;
	using Terrasoft.Core.Entities; 
 
	[ServiceContract]
	[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
	public class EmployeeService
	{
		private static SystemUserConnection _systemUserConnection;
		private static SystemUserConnection SystemUserConnection {
			get {
				return _systemUserConnection ?? (_systemUserConnection = (SystemUserConnection)AppConnection.SystemUserConnection);
			}
		}
 
		[OperationContract]
		[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, 
			BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
		public string ObtenerCantidadLegajosRepetidos(string nroLegajo, string cuitEmpresa)
		{
 
			//var result = nroLegajo + " + output string";
			var result = "T";
			var entitySchemaManager = SystemUserConnection.EntitySchemaManager;
			var employeeSchema = entitySchemaManager.GetInstanceByName("Employee"); 
			var esqEmployee = new EntitySchemaQuery(entitySchemaManager, employeeSchema.Name);
 
			var colId = esqEmployee.AddColumn("Id");
 
			var filtroCUIT = esqEmployee.CreateFilterWithParameters(FilterComparisonType.Equal,"Account.UsrCUIT", cuitEmpresa);
			var filtroLegajo = esqEmployee.CreateFilterWithParameters(FilterComparisonType.Equal,"UsrNroLegajo", nroLegajo);
 
			esqEmployee.Filters.Add(filtroCUIT);
			esqEmployee.Filters.Add(filtroLegajo);
 
			var employeeCollection = esqEmployee.GetEntityCollection(SystemUserConnection);
			if (employeeCollection == null || employeeCollection.Count == 0)
			{
				result = "F";
			}
			return result;
		}
	}
}

Thanks you for your help!

King Regards!

 

Dear Anastasia!

 

I have to say that removing the definition of SystemUserConnection and using UserConnection I get a similar error

King Regards!

Ezequiel

Dear Ezequiel,

Please find the modified code for your service. I have successfully tested it on my side:

namespace Terrasoft.Configuration.Test
{
	using System;
	using System.ServiceModel;
	using System.ServiceModel.Web;
	using System.ServiceModel.Activation;
	using System.Collections.Generic;
	using System.Collections.ObjectModel;
	using System.Data;
	using System.Web;
	using Terrasoft.Common;
	using Terrasoft.Core;
	using Terrasoft.Core.DB;
	using Terrasoft.Core.Entities; 
 
	[ServiceContract]
	[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
	public class EmployeeService
	{
 
		[OperationContract]
		[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, 
			BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
		public string ObtenerCantidadLegajosRepetidos(string nroLegajo, string cuitEmpresa)
		{
			var appConnection = HttpContext.Current.Application["AppConnection"] as AppConnection;
 
			//var result = nroLegajo + " + output string";
			var result = "T";
			var entitySchemaManager = appConnection.SystemUserConnection.EntitySchemaManager;
			var employeeSchema = entitySchemaManager.GetInstanceByName("Employee"); 
			var esqEmployee = new EntitySchemaQuery(entitySchemaManager, employeeSchema.Name);
 
			var colId = esqEmployee.AddColumn("Id");
 
			var filtroCUIT = esqEmployee.CreateFilterWithParameters(FilterComparisonType.Equal,"Account.UsrCUIT", cuitEmpresa);
			var filtroLegajo = esqEmployee.CreateFilterWithParameters(FilterComparisonType.Equal,"UsrNroLegajo", nroLegajo);
 
			esqEmployee.Filters.Add(filtroCUIT);
			esqEmployee.Filters.Add(filtroLegajo);
 
			var employeeCollection = esqEmployee.GetEntityCollection(appConnection.SystemUserConnection);
			if (employeeCollection == null || employeeCollection.Count == 0)
			{
				result = "F";
			}
			return result;
		}
	}
}

 

Dear Andrey,

You have to use only UserConnection in GetEntityCollection method. Here is a signature of a method:

public EntityCollection GetEntityCollection(UserConnection userConnection)

Peter Vdovukhin,

Dear Peter,

Thank you for answer! May be you know how to get UserConnection on start appliacation (without users)? 

Dear Andrey,

Could you create a new topic with this question? It will be available for search and may be helpful for others.

Could you try instead of:

var SysAdminUnitCollection = esqSysAdminUnit.GetEntityCollection(appConnection.SystemUserConnection)

write:

var SysAdminUnitCollection = esqSysAdminUnit.GetEntityCollection((SystemUserConnection)appConnection.SystemUserConnection)

The thing is that SystemUserConnection inherits from UserConnection so you can pass SystemUserConnection instead of UserConnection

 

Show all comments

Hello Community!!

 

I have 2 sections appoint to contact and I regiter this sections in sysModule table and all works ok but the problem is the menssages on the Feed. 

If I put a menssage to ahoter user. When the user want open the message (in the notification Center) I get the function:

 

Terrasoft.ModuleUtils.getEntityStructureByName(entitySchemaName); 

 

TypeError: entityStructure is undefined NetworkUtilities.js:101:8

 

Any know if need register the section in other table related with Feed Notifications?

 

Regards,

 

Like 0

Like

3 comments

Dear Federico,

First of all, we recommend you to create sections via the section wizard, since creating them the way you have described can lead to various conflicts in a database structure. Also, it is not recommended to create two sections, that point to the exact same object for the same reason.

Moreover, we recommend you to debug your customization using your browser's developers tools in case you still want to proceed working with your customization. Also, you can refer to the development documentation for more information.

Best regards,

Matt Watts

Matt Watts,

 Thank you! Can you please give me the code of the function?

Terrasoft.ModuleUtils.getEntityStructureByName(entitySchemaName); may be can check the code to see the error.

Federico Buffa,

You can find the needed method in the ModuleUtils schema of the NUI package.

Here is the code sample you need, but you can refer to the schema if needed.

getEntityStructureByName: function(entitySchemaName) {
			var entityStructure = this.entityStructure || {};
			return entityStructure[entitySchemaName];
		},

Best regards, 

Matt

Show all comments



Hello Community!!

How can add a new Left Container in the LeftModulesContainers? I need a new container with fields like profilecontainer.

Regards,

 

Like 0

Like

3 comments

It seems like you can do this with a section wizard. Just add fields into the container showed on the screenshot below and the system will create a new container automatically. 

 

 

Eugene Podkovka,

 In the custom sections only shows the profilecontainer.

Please add a new container manually and then use "Section wizard" to fill it in.

{

        "operation": "insert",

        "name": "UsrLeftContainer",

        "parentName": "LeftModulesContainer",

        "propertyName": "items",

        "values": {

            "itemType": Terrasoft.ViewItemType.GRID_LAYOUT,

            "items": []

        }

    }

 

Show all comments

Hi,

I am trying to make a php script to add thousands of pictures to existing contacts bpm.

Support helped me already and told that I should create (POST) a new entry in SysImageCollection with json {id: guid, name: guid}.

Then upload the image binary (base64, zipped or not, I tried them all) as an update (PUT) to SysImageCollection(guid'guid')/PreviewData.

Everything runs correct but I don't see any picture change in the contacts.

I use the guid of the contact in both steps.

Maybe I have to use a fresh guid and link that guid to the ContactCollection afterwards?

Does anyone have an idea what the json is to update the the profile picture for a contact?

Thanks in advance,

Kristof Leroux - Laranea

Like 0

Like

7 comments

It's hard to say how to create the integration on PHP. I created the functionality on c# and caught the requests with fiddler.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Net;
using System.Xml;
using System.Xml.Linq;
 
namespace TransferImageViaOData
{
    class Program
    {
        // String of address bpm’online OData servise.
        private const string serverUri = "https://023148-crm-bundle.bpmonline.com/0/ServiceModel/EntityDataService.svc/";
        private const string authServiceUtri = "https://023148-crm-bundle.bpmonline.com/ServiceModel/AuthService.svc/Login";
 
        // Links to XML name spaces.
        private static readonly XNamespace ds = "http://schemas.microsoft.com/ado/2007/08/dataservices";
        private static readonly XNamespace dsmd = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";
        private static readonly XNamespace atom = "http://www.w3.org/2005/Atom";
 
        private static readonly Guid ContactId = new Guid("410006e1-ca4e-4502-a9ec-e54d922d2c00");
 
        static void Main(string[] args)
        {
            var file = ReadFile("z:/2SupportLine/features.png");
            var id = CreateBpmEntityByOdataHttpExample();
            TransferImage(id, "Data", file);
            UpdateContactAvatar(id);
 
        }
 
        public static Guid CreateBpmEntityByOdataHttpExample()
        {
            Guid id = Guid.NewGuid();
            // Creating a xml message containing data on the created object.
            var content = new XElement(dsmd + "properties",
                          new XElement(ds + "Id", id.ToString()),
                          new XElement(ds + "HasRef", 0),
                          new XElement(ds + "MimeType", "image/png"),
                          new XElement(ds + "Name", "test1.png")
                          );
            var entry = new XElement(atom + "entry",
                        new XElement(atom + "content",
                        new XAttribute("type", "application/xml"), content));
            Console.WriteLine(entry.ToString());
            // Creating a request to the service which will add a new object to the contacts collection.
            var request = (HttpWebRequest)HttpWebRequest.Create(serverUri + "SysImageCollection/");
            request.Credentials = new NetworkCredential("Supervisor", "Supervisor");
            request.Method = "POST";
            request.Accept = "application/atom+xml";
            request.ContentType = "application/atom+xml;type=entry";
            // Recording the xml message to the request stream.
            using (var writer = XmlWriter.Create(request.GetRequestStream()))
            {
                entry.WriteTo(writer);
            }
            // Receiving a response from the service regarding the operation implementation result.
            using (WebResponse response = request.GetResponse())
            {
                if (((HttpWebResponse)response).StatusCode == HttpStatusCode.Created)
                {
                    // Processing the operation implementation result.
                }
            }
            return id;
        }
 
        public static void TransferImage(Guid fileRecordId, string columnName, byte[] file)
        {
            // Creating a request to the service which will add a new object to the contacts collection.
            var request = (HttpWebRequest)HttpWebRequest.Create(serverUri + "SysImageCollection(guid'" + fileRecordId.ToString() + "')/" + columnName);
            request.Credentials = new NetworkCredential("Supervisor", "Supervisor");
            request.Method = "PUT";
            request.Accept = "application/octet-stream,application/json;odata=verbose";
            request.ContentType = "multipart/form-data;boundary=+++++";
            // Recording the xml message to the request stream.
            using (Stream requestStream = request.GetRequestStream())
            {
                requestStream.Write(file, 0, file.Length);
            }
            // Receiving a response from the service regarding the operation implementation result.
            using (WebResponse response = request.GetResponse())
            {
                if (((HttpWebResponse)response).StatusCode == HttpStatusCode.Created)
                {
                    // Processing the operation implementation result.
                }
            }
        }
 
        public static void UpdateContactAvatar(Guid fileRecordId)
        {
            var content = new XElement(dsmd + "properties",
                    new XElement(ds + "PhotoId", fileRecordId)
            );
            var entry = new XElement(atom + "entry",
                    new XElement(atom + "content",
                            new XAttribute("type", "application/xml"),
                            content)
                    );
            var request = (HttpWebRequest)HttpWebRequest.Create(serverUri
                    + "ContactCollection(guid'" + ContactId + "')");
            request.Credentials = new NetworkCredential("Supervisor", "Supervisor");
            // or request.Method = "MERGE";
            request.Method = "PUT";
            request.Accept = "application/atom+xml";
            request.ContentType = "application/atom+xml;type=entry";
            // Recording the xml message to the request stream.
            using (var writer = XmlWriter.Create(request.GetRequestStream()))
            {
                entry.WriteTo(writer);
            }
            // Receiving a response from the service regarding the operation implementation result.
            using (WebResponse response = request.GetResponse())
            {
                // Processing the operation implementation result.
            }
        }
 
        public static byte[] ReadFile(string filePath)
        {
            byte[] imageArray = System.IO.File.ReadAllBytes(filePath);
            return imageArray;
        }
    }
}

 

Please use the code below:

<?php

/*Please change this to you product name*/

define("baseUri", "https://023665-crm-bundle.bpmonline.com");

define("serverUri", baseUri . "/0/ServiceModel/EntityDataService.svc");

/*Please change this to you account setting*/

define("user", "Dmitro");

define("password", "123456789");

/*Please change this user_id to new user_id value for the user whose avatar needs to be changed*/

$user_id = 'c4ed336c-3e9b-40fe-8b82-5632476472b4';

/*Please change this file name*/

$file_name = 'test_img.png';

$file_id = CreateBpmEntityFile($file_name);

TransferImage($file_id, $file_name);

UpdateContactAvatar($user_id, $file_id);

function CreateBpmEntityFile($file_name) {

    $headers = [

      'Accept: application/atom+xml',

      'Content-Type: application/atom+xml;type=entry',

      "Authorization: Basic " . base64_encode(user . ':' . password),

      'Expect: 100-continue',

    ];

    $uid = GetUid();

    $postData = <<<XML

<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom"><content type="application/xml"><properties xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><Id xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">$uid</Id><HasRef xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">0</HasRef><MimeType xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">image/png</MimeType><Name xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">$file_name</Name></properties></content></entry>

XML;

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, serverUri . "/SysImageCollection/");

    curl_setopt($ch, CURLOPT_POST, 1);

    curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);

    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

    curl_exec($ch);

    curl_close($ch);

    return $uid;

}

function TransferImage($id, $file_name) {

    $fh_res = fopen($file_name, 'r');

    $xml_data = fread($fh_res, filesize($file_name));

    $headers = [

      "Accept: application/octet-stream,application/json;odata=verbose",

      "Content-type: multipart/form-data;boundary=+++++",

      "Authorization: Basic " . base64_encode(user . ':' . password),

      "Expect: 100-continue",

    ];

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, serverUri . "/SysImageCollection(guid'$id')/Data");

    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");

    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);

    curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE);

    curl_setopt($ch, CURLOPT_POST, TRUE);

    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);

    curl_exec($ch);

    fclose($fh_res);

}

function UpdateContactAvatar($user_id, $file_id) {

    $headers = [

      'Accept: application/atom+xml',

      'Content-Type: application/atom+xml;type=entry',

      "Authorization: Basic " . base64_encode(user . ':' . password),

    ];

    $postData = <<<XML

<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom"><content type="application/xml"><properties xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><PhotoId xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">$file_id</PhotoId></properties></content></entry> 

XML;

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, serverUri . "/ContactCollection(guid'$user_id')");

    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");

    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);

    curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE);

    curl_setopt($ch, CURLOPT_POST, TRUE);

    curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);

    curl_exec($ch);

    curl_close($ch);

}

/**

 * Generate uniq id

 *

 * @return string

 */

function GetUid() {

    $uid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',

      mt_rand(0, 0xffff), mt_rand(0, 0xffff),

      mt_rand(0, 0xffff),

      mt_rand(0, 0x0fff) | 0x4000,

      mt_rand(0, 0x3fff) | 0x8000,

      mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));

    return $uid;

}

 

Mark Bailey,

Thanks Mark for your solution. It is working but I need to use it as a service and my implementation goes like::

 

// Endpoint

        [OperationContract]

        [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped,

        ResponseFormat = WebMessageFormat.Json)]

        public string UploadContactPicture(Data data)

        {

            CifNoVar = data.CIFNo;

            ContactId = Guid.Parse(GetContactIdByCIF(data.CIFNo));

            var file = ReadFile(data.Image);

            var id = CreateBpmEntityByOdataHttpExample();

            TransferImage(id, "Data", file);

            UpdateContactAvatar(id);

            return ContactId.ToString();

        }

 

where Data is::

[DataContract]

    public class Data

    {

        [DataMember]

        public string CIFNo { get; set; }

        [DataMember]

        public string Image { get; set; }

    }

 

The UploadContactPicture is working well to upload a contact picture when my implementation is::

 

[OperationContract]

        [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped,

        ResponseFormat = WebMessageFormat.Json)]

        public string UploadContactPicture(string CIFNo)

        {

            CifNoVar = CIFNo;

            ContactId = Guid.Parse(GetContactIdByCIF(CIFNo));

            var file = ReadFile("E:/SBL_QA/Terrasoft.WebApp/conf/content/img/OBSWConsultationPanelSchema-DefaultContactPhoto.jpg");

            var id = CreateBpmEntityByOdataHttpExample();

            TransferImage(id, "Data", file);

            UpdateContactAvatar(id);

            return ContactId.ToString();

        }

 How can I use a JSON object(Model object) as a parameter to the UploadContactPicture method to successfully upload a picture as shown in the example above. 

Dear,

In order to resolve the issue please use the article by the link below:

 

https://stackoverflow.com/questions/52489002/get-the-object-is-null-using-json-in-wcf-service/52497740#52497740

 

Best regards,

Norton

Norton Lingard,

Hi Norton, thanks for your reply. I had tried it, but it didn't work. It says::

403 - Forbidden: Access is denied. You do not have permission to view this directory or page using the credentials that you supplied.

This is my full implementation::

namespace Terrasoft.Configuration.SBLCustomNamespace

{

    using System;

    using System.ServiceModel;

    using System.ServiceModel.Web;

    using System.ServiceModel.Activation;

    using Terrasoft.Core;

    using Terrasoft.Web.Common;

    using Terrasoft.Core.Entities; 

    using Terrasoft.Core.DB;

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.IO;

    using System.Linq;

    using System.Net;

    using System.Xml;

    using System.Xml.Linq;

    using System.Web.Hosting;

    using System.Runtime.Serialization;

    

    [DataContract]

    public class Data

    {

        [DataMember]

        public string CIFNo { get; set; }

        [DataMember]

        public string Image { get; set; }

    }

    [ServiceContract]

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]

    public class SBLContactPictureUploaderService: BaseService

    {

        // Link to the UserConnection instance required to access the database.

        private SystemUserConnection _systemUserConnection;

        private SystemUserConnection SystemUserConnection {

            get {

                return _systemUserConnection ?? (_systemUserConnection = (SystemUserConnection)AppConnection.SystemUserConnection);

            }

        }

        

        // String of address bpm’online OData service.

        private const string serverUri = "https://qacrm.siddharthabank.com/0/ServiceModel/EntityDataService.svc/";

        private const string authServiceUtri = "https://qacrm.siddharthabank.com/ServiceModel/AuthService.svc/Login";

 

        // Links to XML name spaces.

        private readonly XNamespace ds = "http://schemas.microsoft.com/ado/2007/08/dataservices";

        private readonly XNamespace dsmd = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";

        private readonly XNamespace atom = "http://www.w3.org/2005/Atom";

 

        private Guid ContactId = Guid.NewGuid();

        

        private string CifNoVar = string.Empty;

 

         // A method that returns the contact's ID by its name.

        [OperationContract]

        [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare,

        ResponseFormat = WebMessageFormat.Json)]

        public string UploadContactPicture(Data data)

        {

            CifNoVar = data.CIFNo;

            ContactId = Guid.Parse(GetContactIdByCIF(data.CIFNo));

            var file = ReadFile(data.Image);

            var id = CreateBpmEntityByOdataHttpExample();

            TransferImage(id, "Data", file);

            UpdateContactAvatar(id);

            return ContactId.ToString();

        }

        

        public Guid CreateBpmEntityByOdataHttpExample()

        {

            Guid id = Guid.NewGuid();

            // Creating a xml message containing data on the created object.

            var content = new XElement(dsmd + "properties",

                          new XElement(ds + "Id", id.ToString()),

                          new XElement(ds + "HasRef", 0),

                          new XElement(ds + "MimeType", "image/jpg"),

                          new XElement(ds + "Name", CifNoVar.ToString().Trim()+".jpg")

                          );

            var entry = new XElement(atom + "entry",

                        new XElement(atom + "content",

                        new XAttribute("type", "application/xml"), content));

            Console.WriteLine(entry.ToString());

            // Creating a request to the service which will add a new object to the contacts collection.

            var request = (HttpWebRequest)HttpWebRequest.Create(serverUri + "SysImageCollection/");

            request.Credentials = new NetworkCredential("Supervisor", "Supervis0r@1234%");

            request.Method = "POST";

            request.Accept = "application/atom+xml";

            request.ContentType = "application/atom+xml;type=entry";

            // Recording the xml message to the request stream.

            using (var writer = XmlWriter.Create(request.GetRequestStream()))

            {

                entry.WriteTo(writer);

            }

            // Receiving a response from the service regarding the operation implementation result.

            using (WebResponse response = request.GetResponse())

            {

                if (((HttpWebResponse)response).StatusCode == HttpStatusCode.Created)

                {

                    // Processing the operation implementation result.

                }

            }

            return id;

        }

 

        public void TransferImage(Guid fileRecordId, string columnName, byte[] file)

        {

            // Creating a request to the service which will add a new object to the contacts collection.

            var request = (HttpWebRequest)HttpWebRequest.Create(serverUri + "SysImageCollection(guid'" + fileRecordId.ToString() + "')/" + columnName);

            request.Credentials = new NetworkCredential("Supervisor", "Supervis0r@1234%");

            request.Method = "PUT";

            request.Accept = "application/octet-stream,application/json;odata=verbose";

            request.ContentType = "multipart/form-data;boundary=+++++";

            // Recording the xml message to the request stream.

            using (Stream requestStream = request.GetRequestStream())

            {

                requestStream.Write(file, 0, file.Length);

            }

            // Receiving a response from the service regarding the operation implementation result.

            using (WebResponse response = request.GetResponse())

            {

                if (((HttpWebResponse)response).StatusCode == HttpStatusCode.Created)

                {

                    // Processing the operation implementation result.

                }

            }

        }

 

        public void UpdateContactAvatar(Guid fileRecordId)

        {

            var content = new XElement(dsmd + "properties",

                    new XElement(ds + "PhotoId", fileRecordId)

            );

            var entry = new XElement(atom + "entry",

                    new XElement(atom + "content",

                            new XAttribute("type", "application/xml"),

                            content)

                    );

            var request = (HttpWebRequest)HttpWebRequest.Create(serverUri

                    + "ContactCollection(guid'" + ContactId + "')");

            request.Credentials = new NetworkCredential("Supervisor", "Supervis0r@1234%");

            // or request.Method = "MERGE";

            request.Method = "PUT";

            request.Accept = "application/atom+xml";

            request.ContentType = "application/atom+xml;type=entry";

            // Recording the xml message to the request stream.

            using (var writer = XmlWriter.Create(request.GetRequestStream()))

            {

                entry.WriteTo(writer);

            }

            // Receiving a response from the service regarding the operation implementation result.

            using (WebResponse response = request.GetResponse())

            {

                // Processing the operation implementation result.

            }

        }

 

        public static byte[] ReadFile(string filePath)

        {

            byte[] imageArray = System.IO.File.ReadAllBytes(filePath);

            return imageArray;

        }

        

        // A method that returns the contact's ID by its name.

        [OperationContract]

        [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped,

        ResponseFormat = WebMessageFormat.Json)]

        public string GetContactIdByName(string Name){

            // The default result.

            var result = "";

            // An EntitySchemaQuery instance that accesses the Contact table of the database.

            var esq = new EntitySchemaQuery(SystemUserConnection.EntitySchemaManager, "Contact");

            // Adding columns to the query.

            var colId = esq.AddColumn("Id");

            var colName = esq.AddColumn("Name");

            // Filter the query data.

            var esqFilter = esq.CreateFilterWithParameters(FilterComparisonType.Equal, "Name", Name);

            esq.Filters.Add(esqFilter);

            // Get the result of the query.

            var entities = esq.GetEntityCollection(SystemUserConnection);

            // If the data is received.

            if (entities.Count > 0)

            {

                // Return the value of the "Id" column of the first record of the query result.

                result = entities[0].GetColumnValue(colId.Name).ToString();

                // You can also use this option:

                // result = entities [0]. GetTypedColumnValue <string> (colId.Name);

            }

            // Return the result.

            return result;

        }

        

        public string GetContactIdByCIF(string CIFNo){

            // The default result.

            var result = "";

            // An EntitySchemaQuery instance that accesses the Contact table of the database.

            var esq = new EntitySchemaQuery(SystemUserConnection.EntitySchemaManager, "Contact");

            // Adding columns to the query.

            var colId = esq.AddColumn("Id");

            var colName = esq.AddColumn("SBLCIF");

            // Filter the query data.

            var esqFilter = esq.CreateFilterWithParameters(FilterComparisonType.Equal, "SBLCIF", CIFNo);

            esq.Filters.Add(esqFilter);

            // Get the result of the query.

            var entities = esq.GetEntityCollection(SystemUserConnection);

            // If the data is received.

            if (entities.Count > 0)

            {

                // Return the value of the "Id" column of the first record of the query result.

                result = entities[0].GetColumnValue(colId.Name).ToString();

                // You can also use this option:

                // result = entities [0]. GetTypedColumnValue <string> (colId.Name);

            }

            // Return the result.

            return result;

        }

        

        [OperationContract]

        [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped,

        ResponseFormat = WebMessageFormat.Json)]

        public string InsertContact(string contactName)

        {

            contactName = contactName ?? "Unknown contact";

            var ins = new Insert(UserConnection)

                .Into("Contact")

                .Set("Name", Column.Const(contactName));

            var affectedRows = ins.Execute();

            var result = $"Inserted new contact with name '{contactName}'. {affectedRows} rows affected";

            return result;

        }

    }

}

 

Dear,

 

In order to resolve the issue please use the article by the link below:

 

https://community.creatio.com/questions/403-forbidden-when-using-post-custom-service

 

Best regards,

Norton

Show all comments

Hi All,

We would like to put extra filter on a detail.



For example: A list of open opportunities. I could not file good example in the documentaion.



Is there anyone who has same experience?

Like 0

Like

2 comments
Best reply

Dear Cheng,

You can use the Email detail from the Contact page as an example. There is a fixed filter there that allows the user to see the activities with the certain category (Email) only. 

The schema looks like this:

EmailDetailV2: {
   schemaName: "EmailDetailV2",
   filter: {
      masterColumn: "Id",
      detailColumn: "Contact"
   },
   filterMethod: "emailDetailFilter"
}

You need to pay attention to the filterMethod usage and create the necessary ESQ filters inside the method:

filterGroup.add(
   "EmailFilter",
   this.Terrasoft.createColumnFilterWithParameter(
      this.Terrasoft.ComparisonType.EQUAL,
      "Type",
      ConfigurationConstants.Activity.Type.Email
   )
);

Lisa

Dear Cheng,

You can use the Email detail from the Contact page as an example. There is a fixed filter there that allows the user to see the activities with the certain category (Email) only. 

The schema looks like this:

EmailDetailV2: {
   schemaName: "EmailDetailV2",
   filter: {
      masterColumn: "Id",
      detailColumn: "Contact"
   },
   filterMethod: "emailDetailFilter"
}

You need to pay attention to the filterMethod usage and create the necessary ESQ filters inside the method:

filterGroup.add(
   "EmailFilter",
   this.Terrasoft.createColumnFilterWithParameter(
      this.Terrasoft.ComparisonType.EQUAL,
      "Type",
      ConfigurationConstants.Activity.Type.Email
   )
);

Lisa

Lisa Brown,

Thank you. It works now.

Show all comments

How can we add a Product Image in the Product Selection page in the [Orders] section? Please suggest.

Like 0

Like

1 comments

Dear Anupama,

This is a quite complex functionality to implement, which requires developer's skills. In the core, the idea is to add one extra column to the grid of product selection page and display product image there.

In order to add extra field to the grid you need to do the following:

1. Add the ProductSelectionViewModel replacing schema

2. Copy all the code to the replaced schema from the parent schema

3. Add Dependencies as in the parent schema

4. Add a custom variable in all methods where the standard fields "Unit, Price , Currency, Tax, Code, Available" are

5. Save the replaced schema

6. Add the ProductSelectionView replacement schema

7. Copy all the code to the replaced schema from the parent

8. Add Dependencies from the parent schema

9. In the getEditableGridConfig and getGridCaptionConfig methods, add the custom field for the picture

 10. Save replacement schema

By the means of basic JS methods like "getImageURL" (it is also present in the ProductSelectionViewModel schema) insert image to the  column. You can also take a product page as an example of usage of image functionality.

Hope you find it helpful.

Regards,

Anastasia

Show all comments

Hello Community!

I need filter the folder all (pre filter on load) the idea is show only contacts by specific type in the list but the user can change the filter.

Any idea?

Like 0

Like

5 comments

Dear Federico,

We have the great manual on how to add the fixed filter to the section in our Academy - https://academy.bpmonline.com/documents/technic-sdk/7-11/how-add-fixed-filters-block-section.

You can use it as an example. Just replace the FixedFilter by FolderFilter.

Lisa

 

Lisa Brown,

The example is working with a date duration and a owner field (LOOKUP). Is it possible to do the following?

1. Filter on a TEXT column.

2. The column is in the linked object. For example, Contact.Account.Name. Assume we are working on the ContactSectionV2

 

Dear Federico,

Yes, both cases described by you can work:

1. You can work with the text column with help of this filters: http://prntscr.com/hy36o6

2. This is how you should set up the folder's filter in order to filter by Account.Name: http://prntscr.com/hy363s

You can work with almost every type of column (like boolean, text. lookup etc.).

With best regards,

Oliver

Oliver,

What we asked is a fixed filter instead of advanced filter. I know that by using the advanced filter we can do most of search as we want. On the other hand the fixed filter has its limitation.

Dear Cheng,

Every filter you can build with the help of the advanced filters in the folder/sections is possible to build in the form of the fixed filters. There are no known limitations for the development of the functionality. 

Lisa

Show all comments

Hi Community!

How are you? I hope you can help me!

I have configured permissions managed by operations, in which I restrict reading to contacts for certain roles. That brings me problems when reading contact data from a business process, even though it gives permission to the contact from the process, the reading does not work. How could I hide the contacts section without losing access to them from another object?

King Regards!

Ezequiel!

Like 0

Like

3 comments

Dear Ezequiel,



If your goal is just to hide the contacts section but you want to get the ability to read the contacts information for all users, you can try to delete it from the General workplace so that all employees won't see it and restore the read operation permissions to all system users.



System designer -> Workplace setup:

Image.png

You can add this section to any other workplace and manage the access rules to it or create your own to fulfill your needs.

Best regards,

Lily

Hi Lily!

Thanks for the reply. I delete the section from the General workplace and restore the read operation permissions to all system users. How could I hide the link to Contacts from the main page?

 

 

 

 

King Regards,

Ezequiel Gómez

Dear Ezequiel,

To hide the link to the section from the main page you need to go to the Configuration, replace SimpleIntro schema, copy the code from the original schema to it and apply the necessary changes to the code. Specifically, to hide the link to the Contacts section, you need to comment the following code part:

Image.png

Show all comments
Question
Hi, I need to advise. I use an external file in my BPM online application. Is it
 possible to save this file directly somewhere in BPM online? E.g. in a custom 
package or other storage. I would like to test in the BPM trial version online,
 so I can not get to the local disk to save the file.
Like 0

Like

1 comments

Dear Marcela,

You can save the file to the Attachments and Notes detail that is available in different sections of the system for example on the Contact or Account page. Please note that there is a limit for the attachment size - 10 Mb by default though it may be changed with the help of the MaximumAttachmentSize system settings.

Lisa

Show all comments