Dear Community,

 

I am trying to copy values from a field and lookups to put it in the "Name" fields before saving.

I use the following code in the script task but I don't know how to get the value from a lookup:

Entity.Name = $"{Entity.Code } - {Entity.Description}";

Code being the lookup.



So if you create a record in a lookup it would go like this:

[Name][Code][Description]

[           ][ 001 ][Code for info]



The Name should automatically be filled with "001 - Code for info" after saving.

What is the correct way to set the script?

Thank you!

 

 

Kind regards,

Yosef

 

Like 0

Like

2 comments

Hi!

 

Just add on saving event in your lookup entity, and add a script

 

Entity.SetColumnValue("Name", string.Format("[{0}][{1}]", Entity.GetTypedColumnValue<string>("Code"), Entity.GetTypedColumnValue<string>("Descritpion"));

 

Dmytro Oliinyk,

 

 

Thank you but that didn't seem to work for me, this was the solution for me:

 

var name = Entity.GetColumnValue("Name");
var description = Entity.GetColumnValue("Description");
 
var esq = new EntitySchemaQuery(Entity.Schema);
esq.AddColumn("Code.Name");
 
var CodeEntity= esq. GetEntity(UserConnection, Entity.PrimaryColumnValue);
if (CodeEntity != null) {
 
	var columnUsrCodeName = CodeEntity .GetTypedColumnValue<string>("Code_Name");
 
	string fullName= $"{name}: {columnUsrCodeName } - {description}";
	Entity.SetColumnValue("Name", fullName);
}
return true;

Let me know if there's an easier way to do this.

 

 

Kind regards,

Yosef

Show all comments

Which C# data type (decimal, double, etc) should I use in a script task "Get("ProcessParameter")" for decimal process parameters?

 

Like 0

Like

2 comments

Hi Ricardo

You should use System.decimal C# type.

And it's a C# structure in .NET and .NET Core.

https://docs.microsoft.com/en-us/dotnet/api/system.decimal?view=netcore…

 

Thank you

Mohamed

 

Hi Ricardo, 

 

Indeed, you can use System decimal C# type as Mohamed mentioned above. However, in case of any difficulties, please try the standard int datatype.

 

Regards, 

Anastasiia

Show all comments

How to apply access permissions (object permission) / access right when insert data via server-side?

I have set the record access permission, but when inserting via server-side, the access right does not work. The insert method that I did was in accordance with the article above.

Thanks.

Like 0

Like

1 comments

Hi,

It is possible adding data via server-side with access permissions using the “Entity” class. Please find more information with the examples by the link below:

https://academy.bpmonline.com/documents/technic-sdk/7-13/working-database-entity-class

Best regards,

Norton  

Show all comments

Is there a way to read all the users inside an organizational role and then send those email addresses to the next step of a process?

Like 0

Like

2 comments

The functionality can be implemented using a script task element in order to select all contact emails which are included in the role. The contact emails are selected from the database via EntitySchemaQuery. Then join all selected emails into a string using ";" as separator. After that use the newly built string of emails as an email for sending.

The basic business process "Send email to case group" works in the same way. Please feel free to use the business process as an example. Pay attention to the script task element "Prepare Recipient Emails" (https://prnt.sc/p0tv3t).

Show all comments

Good day.

I am new to BPM Online(And C#). I just registered a 14 day free account to try it out.

I want to use the sub process to create a case number when a new record is created on a section. Please see the image below:

When the new record is saved the process starts and reads the zone filed from the request record as depicted below:

Upon reading the zone field I then assign the zone filed to the zone process variable using the formular task as depicted below:

I then use the zone process variable to formulate the case number in the code script as depicted below:

string unique_numer =  DateTime.Now.ToString("yyMMddhhmmss");
string  zone_val = Get<Guid>("zone").ToString();
string case_number=(zone_val+"-"+unique_numer)
 
Set("case_number",case_number);
return true;

The challenge I am facing is to get the value of the selected lookup zone field to store the value into zone_val string filed.

How to get the selected value from the zone lookup filed using C# code. The value that I get is a Guid data type and cannot get the value of the lookup.

I need to store the generated CaseNumber to the case_number field in the database as depicted below:

You help will be highly appreciated as I am currently stuck.

 

Like 0

Like

4 comments

Dear Tebogo,

You may create a system setting that will store this number and use it in the future number generation. You can find detailed example here: https://academy.bpmonline.com/documents/technic-sdk/7-13/how-add-auto-n…

Best regards,

Angela

Assuming you want the field name in the Zone Table : 

var uc = Get&lt;UserConnection&gt;("UserConnection");
 
Guid zoneId = Get&lt;Guid&gt;("zone");
 
var esq = new EntitySchemaQuery(uc.EntitySchemaManager.GetInstanceByName("Zone"));
esq.AddColumn("Name");
var entity = esq.GetEntity(uc, zoneId );
string zoneName = entity.GetTypedColumnValue&lt;string&gt;("Name");

 

Angela Reyes,

Thank you very much Angela.

Jerome BERGES,

Thank you very much Jerome, highly appreciate it!

Show all comments

Hi Community,

This code below gets the Guid of the current user in client side code

Terrasoft.SysValue.CURRENT_USER.value

How about in script task, using C# code what is its equivalent?

 

 

Like 0

Like

4 comments

In a script task you have access to UserConnection. This exposes a  CurrentUser property (which provides an object of type SysUserInfo). 

var currentUser = UserConnection.CurrentUser;
var userId = currentUser.Id;
var userName = currentUser.Name;

BTW If this was code in a source code schema/configuration service, you'd need to get the UserConnection via the AppConnection first:

var appConnection = HttpContext.Current.Application["AppConnection"] as AppConnection;
var currentUser = appConnection.SystemUserConnection.CurrentUser;

 

Ryan Farley,

Thanks Ryan,

Is there any documentation about CurrentUser. I want to know everything about its properties and attributes for future use.

Thanks.

Fulgen Ninofranco,

I don't know of any documentation, it is in Terrasoft.Core.dll, however, the SysUserInfo object inherits from the SysAdminUnit object. This object you can see in the configuration. Search for SysAdminUnit in the configuration and you'll see what is available in the SysUserInfo. The SysUserInfo object itself only adds 5 additional properties for TimeZone, PageRowsCounr, Culture, ClientIP, and DateTimeFormatCode.

Dear Fulgen,

Please use the example mentioned by Ryan, it covers the way you work with UserConnection in Script Task. 

var currentUser = UserConnection.CurrentUser;

For more information on all .Net classes used in the system please see this article:

https://academy.bpmonline.com/api/netcoreapi/7.13.0/index.html#GeneralS…

Also, as for examples of UserConnection usage in web services you can check the examples here:

https://academy.bpmonline.com/documents/technic-sdk/7-13/how-create-cus…

 Regards,

Anastasia

Show all comments