How can i hide / show a field based on the user role in freedom UI with business rules or with js code?

Thank you

Like 2

Like

6 comments
Best reply

You can do this with code on a Freedom UI page. 

1) Make sure you add "@creatio-devkit/common" to the page as sdk

2) First add an attribute to the viewModelConfig. I'll call the attribute "IsUserInRole since we'll set it to true/false if the user is in the role. 

viewModelConfig: /**SCHEMA_VIEW_MODEL_CONFIG*/{
    "attributes": {
        "IsUserInRole": {}
    }
}/**SCHEMA_VIEW_MODEL_CONFIG*/

3) Bind the attribute to the visible property of the control by adding the following to the control in the viewModelDiff

"visible": "$IsUserInRole"

4) Now when the view model is initialized, basically the Freedom UI equivalent of the onEntityInitialized on classic pages, do a query using the model to determine if the current user is in the role. We'll use that result to set the attribute:

{
    request: "crt.HandleViewModelInitRequest",
    handler: async (request, next) => {
        await next?.handle(request);
        // get current user
        const sysValuesService = new sdk.SysValuesService();        
        const sysValues = await sysValuesService.loadSysValues();
        const currentUserContact = sysValues.userContact;
 
        // create model query
        userRoleModel = await sdk.Model.create("SysUserInRole");
        const filter = new sdk.FilterGroup();
        await filter.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "SysRole.Name", "The Role Name Here");
        await filter.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "SysUser.Contact", currentUserContact.value);
 
        // workaround for filters, will be fixed in 8.1
        const newFilter = Object.assign({}, filter);
        newFilter.items = filter.items;
 
        const results = await userRoleModel.load({
            attributes: ["Id"],
            parameters: [{
                type: sdk.ModelParameterType.Filter,
                value: newFilter
            }]
        });
 
        // now set attribute
        request.$context.IsUserInRole = results.length > 0;
    }
}

I didn't test that code, but it should be pretty close. If anything you might need to play with the filter for the model query.

Ryan

Hello,

 

Unfortunately, there is no way to add visibility to the field based on user role via Section Wizard.

 

But we've registered it in our R&D team backlog for consideration and implementation in future application releases.

 

Thank you for helping us to improve our product. 

Bogdan,

but is it possible to calculate page parameter based on Operation permission? And then use this parameter in business rule?

You can do this with code on a Freedom UI page. 

1) Make sure you add "@creatio-devkit/common" to the page as sdk

2) First add an attribute to the viewModelConfig. I'll call the attribute "IsUserInRole since we'll set it to true/false if the user is in the role. 

viewModelConfig: /**SCHEMA_VIEW_MODEL_CONFIG*/{
    "attributes": {
        "IsUserInRole": {}
    }
}/**SCHEMA_VIEW_MODEL_CONFIG*/

3) Bind the attribute to the visible property of the control by adding the following to the control in the viewModelDiff

"visible": "$IsUserInRole"

4) Now when the view model is initialized, basically the Freedom UI equivalent of the onEntityInitialized on classic pages, do a query using the model to determine if the current user is in the role. We'll use that result to set the attribute:

{
    request: "crt.HandleViewModelInitRequest",
    handler: async (request, next) => {
        await next?.handle(request);
        // get current user
        const sysValuesService = new sdk.SysValuesService();        
        const sysValues = await sysValuesService.loadSysValues();
        const currentUserContact = sysValues.userContact;
 
        // create model query
        userRoleModel = await sdk.Model.create("SysUserInRole");
        const filter = new sdk.FilterGroup();
        await filter.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "SysRole.Name", "The Role Name Here");
        await filter.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "SysUser.Contact", currentUserContact.value);
 
        // workaround for filters, will be fixed in 8.1
        const newFilter = Object.assign({}, filter);
        newFilter.items = filter.items;
 
        const results = await userRoleModel.load({
            attributes: ["Id"],
            parameters: [{
                type: sdk.ModelParameterType.Filter,
                value: newFilter
            }]
        });
 
        // now set attribute
        request.$context.IsUserInRole = results.length > 0;
    }
}

I didn't test that code, but it should be pretty close. If anything you might need to play with the filter for the model query.

Ryan

Thank you. That helps a lot.

Ryan Farley,



I have tried a similar case, where on saving a record writing a validation to check whether it has unique "Code".

 

request: "crt.SaveRecordRequest",handler: async (request, next) => {
// Add any code to execute *before* the save here
 
var accountModel = await sdk.Model.create("Account");
 
const filter = new sdk.FilterGroup();
var codeValue = await request.$context.StringAttribute_enupz4g;
await filter.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "SMCode", codeValue);
 
	const newFilter = Object.assign({}, filter);
	newFilter.items = filter.items;
 
	const accounts = await accountModel.load({
		attributes: ["Id"],
		parameters: [{
		type: sdk.ModelParameterType.PrimaryColumnValue,
		value: newFilter
		}]
	});
	if(accounts.length > 0){
		isSave = false;
		//Show warning Message
		request.$context.executeRequest({
		type: "crt.ShowDialogRequest",
		$context: request.$context,
		dialogConfig: {
		data: {
		message: "Code already already exists",
		actions: [{
			key: "OK",
			config: {
			color: "primary",
			caption: "OK"
			}
		}]
		}
		}
	});
	}
else{
return next.handle(request);
}
}



I followed your code to check any account has the similar code. Seems like, there is an issue in the filter it throws the below error.







Can you help me in adding the proper filter in this Freedom UI? Or provide a sample code to add filters to retrive data from an entity.



Regards,

Adharsh S

Adharsh,

Change this part: 

const accounts = await accountModel.load({
	attributes: ["Id"],
	parameters: [{
		type: sdk.ModelParameterType.PrimaryColumnValue,
		value: newFilter
	}]
});

To this: 

const accounts = await accountModel.load({
	attributes: ["Id"],
	parameters: [{
		type: sdk.ModelParameterType.Filter,
		value: newFilter
	}]
});

Note, the difference in type. You're specifying a filter, not providing a primary column value. 

Ryan

Show all comments

Hi Everyone,

 

We have Loads in our environment and teams into which those loads are supposed to be divided equally. I want to know how can i do this with the business process?

Like 0

Like

4 comments

Hello, 

Thank you for your question!

Please note that the decimal separator logic is hard coded within the system core. Unfortunately, it is not possible to change it using basic user tools and we do not have a ready-made solution to resolve your problem.



We have already registered the following suggestion for our R&D department and they will consider the implementation of this functionality in future releases.

 

Viktoriia Hrynchuk,

Hi Vik,

 

Thank you for your response. If I have a Decimal variable of .00, then I can use it to divide into the same Decimal variable?

Hello!

 

To divide one number by another in a business process, we recommend using the "Formula" element available in Creatio. 

For detailed guidance on using the "Formula" element and other functionalities in Creatio, we encourage you to explore the Creatio Academy.

https://academy.creatio.com/docs/8-0/user/bpm_tools/business_process_se…

There, you will find comprehensive tutorials, guides, and resources that will help you make the most of our platform's capabilities.

 

Best regards,

Kate

Kate Karpik,

HI Kate,

 

Thank you for your response. I don't see anything regarding division in the academy.

Show all comments

Hi,

I have 2 VMs for Creatio v8.0.8.4807:

1 on Windows Server 2016 wirh iis where located all Creatio files

2 on Ubuntu 20 with Postgres 12 + Redis

So after all installation steps i face with a problem 

Config Error   The configuration section 'terrasoft' cannot be read because it is missing a section declaration

Config File   \\?\C:\inetpub\wwwroot\8.0.8.4807_ServiceEnterprise_Softkey_PostgreSQL_ENU\Terrasoft.WebApp\web.config

I have checked web.config and ConnectionString and all seems fine

Also attached the error screen and in rar format web.config + ConnectionString



Thanks in advance

 

File attachments
Like 0

Like

3 comments

Hi @Babyshark! How are you? I strongly recommend to double check the necessary windows componentes: https://academy.creatio.com/docs/7-18/user/on_site_deployment/applicati…

Regards.

Uriel Nusenbaum,

Hi, Uriel

I have checked everything and all seems installed. Unfortunately still have the same problem. No idea how to solve the issue.



Thanks for trying to help me.

You are welcome! If you want you could share a print with the result of this command. Please see the image below:

 

Thank you

Regards.

Show all comments

Where can we find documentation on actualization?  Need to understand what it means in different contexts and its impact when actualize.

For lookup fields, we know that actualization refreshes the latest set of available data, from which can select for binding purposes.



What does it mean in other contexts?   eg SysDcmSettings, SysDcmInSchemaSettings, EntityConnection, DocumentState, SysDetail, SysModuleEdit, SysModuleEntity, SusModuleInWorkplace, SysModuleVisa, SysModule, SysWidgetDashboard, TimelinePageSetting, UsrOrderingandAssembly, UsrRequestStage, OAuthAppScope, OAuthApplications, SysSettings.

Like 0

Like

4 comments

Hello,

 

Please provide us with more details regarding your question, so that we can assist you properly.

 

Best regards,

Yuliya

Yuliya Gritsenko,

Hi Yuliya, in Advanced Settings we are viewing items which Need Actualisation (filter next to Type, under All items).  This is showing many items which need actualisation, across multiple packages. 

For Lookups we know what actualisation means, its impact and how to leverage/manage it.

For all other Item types, we are looking to understand what actualisation does in the context of each item type (eg SysDcmSettings, SysDetail, TimelinePageSetting) per list above.

We intend to do the actualisation for each item, then recompile, just want to make sure we will not break anything.

Example screenshot...

 

 

Hello,

 

These are system tables. If you set the data, you will thereby update the existing data. However, it depends on the data settings you specify, whether to update values or directly insert them.

Therefore, it's advisable to create a backup before installation so that you can revert everything back in case of any issues.

 

https://academy.creatio.com/docs/developer/development_tools/creatio_id…

Sergii Zhmurko,

Thanks Sergii, I've read the documentation (Data & the related Operations in Creatio IDE).  2 follow up qus please:

1) what are the considerations "whether to update values or directly insert them"?

2) Does the bulk action "Install data" update the existing data for all selected elements? (see screenshot)

Show all comments

Hello,

We have a page with a lot of fields and details. And this page should be used in Mobile App on iPad's.

Currently FreedomUi selects layout automaticaly, so fields and details are located not in order of business logic.

Can we use something like Tabs in mobile App?

Can we control layout and define where exact field or detail should be on the screen?



Thank you very much!

Vladimir

Like 3

Like

3 comments

Maybe Creatio 8.0.10 ?



Custom layouts for mobile. You can now have more control over the layout of mobile Freedom UI pages by setting up custom layouts in page metadata. For example, you can specify the order of Area layout elements.



https://academy.creatio.com/docs/release/release-notes/8010-atlas-relea…

Damien Collot,

Thank you, 

That's greate news. The only questions is how to do that. I haven't found any options for that in 8.0.10 trial

Hello!

 

In case in your mobile application the Freedom UI is set for the definite section, you can easily correct the elements layout for the tablet with help of metadata.

 

In case you will have any additional questions on this matter, just let me know. 

Show all comments

Has anybody figured out how to include landing pages integrated webhooks in marketing automation campaigns in nocode ?

Like 0

Like

3 comments

I have unbounce landing pages that are using webhooks in Creatio but haven't figured out how to use it in campaigns yet. I'm assuming I just need to populate a table somewhere, but just starting to piece it together so not sure yet

Ryan

Hello,

 

At the moment, there is no separate element for working with web hooks in marketing campaigns yet. If what's needed is to add such contacts to the audience of the campaign, then this can be done with the help of the  appropriate filtering based on data from the record that came from a landing page, taking into account the channel, source, tags (if necessary for the case).

So you get leads from landing pages, put these leads in a separate folder and create a mailing list in the campaign that will take the audience from this folder.

Is there any plan to make easily part of marketing automation campaigns like the classic landing page element is ?

Show all comments

Using the new case management composable app, can we create cases with webhook (Eg: from support contact page on website)?



And can you populate the webhook with predefined values in addition to the form fields ?

Like 0

Like

3 comments
Best reply

Yes. You can add a Case (or any entity) using a webhook. All you need to do is specify EntityName: Case in the payload and include any of the fields needed for the case, including any default values. 

What I've not tested yet (and I suspect cannot be done with a webhook) is include a nested payload for related data - such as an account)

Yes. You can add a Case (or any entity) using a webhook. All you need to do is specify EntityName: Case in the payload and include any of the fields needed for the case, including any default values. 

What I've not tested yet (and I suspect cannot be done with a webhook) is include a nested payload for related data - such as an account)

You can also specify in webhook an entity which will be used as an intermediate object before case registration. 

For ex, Submitted form. 

You will need to add your case relating fields in Submitted form (including nested payload) and then to write a process which will be triggered when a form is submitted and 

to manage nested data, perform any searches and register a case from this process.

More than using the webhook to entity conversion using the OOTB process, I've been just adding my own. If the payload from the webhook doesn't contain an "EntityName" the ootb process rejects it, however, you can still create your own process that triggers from a signal of webhook added, plus you can add filters for the headers or payload containing some specific values. Then deserialize the JSON payload and do whatever you want with it. I'll have an article written up on this topic soon.

Ryan

Show all comments

Hello everyone,

I'm trying to create a business process where I'll be able to modify the currency "rate" value (I have my own data source), but I can't see this field to modify. This is the only field from the 'Currency' lookup which I cannot choose. Could you please tell me what I need to do? Thank you a lot in advance.

Like 0

Like

3 comments
Best reply

Damian Rynkowski,

The Exchange rate column in the Currency object is virtual, so it is not shown in the Lookup and cannot be edited directly from the Lookup.

The Rate itself is saved in the CurrencyRate table with a link to CurrencyId each time it is changed.



The base stores the inverse of the exchange rate. For example:

Base currency:  人民幣(RMB)

Dollar exchange rate: 0,15



Which is inconvenient to understand, so a Lookup with a more user-friendly currency display, but converting to a reverse exchange rate, has been developed to support backward compatibility.

This way you can enter the usual exchange rate of USD = 6.79 (RMB to USD) on the interface. And the base will already save 0.15 (USD per 1 RMB).

 

These different types of rate (6.79 and 0.15) will determine the formula by which you will then calculate the amounts. You can read from the CurrencyRate table and get a rate of 0.025 and:

1) convert it to a familiar rate - 1/0.15 = 6.79.

2) either work already with 0.15, but then the calculation of the amount will be different.



So, the Rate column is virtual, but you can use CurrencyRate (exchange rate) to calculate the exchange rate.

Hello,

 

Please note that you can easily change the "rate" column of the Currencies lookup in the lookups content:

If you need to change it specifically via buiness process, can you please specify what for and what is the business logic you are trying to achieve this way?

Mira Dmitruk,

Hi,

Thank you for your reply. I am aware that I can modify this column through a lookup, but what I really need is to automate this process.

 

I have currency rates stored in different lookups, and I want to create an automated process to update the currency values every night. Currently, I am unable to modify the "Rate" field directly because it is not visible in the business process editor when the Currency object is selected.

Damian Rynkowski,

The Exchange rate column in the Currency object is virtual, so it is not shown in the Lookup and cannot be edited directly from the Lookup.

The Rate itself is saved in the CurrencyRate table with a link to CurrencyId each time it is changed.



The base stores the inverse of the exchange rate. For example:

Base currency:  人民幣(RMB)

Dollar exchange rate: 0,15



Which is inconvenient to understand, so a Lookup with a more user-friendly currency display, but converting to a reverse exchange rate, has been developed to support backward compatibility.

This way you can enter the usual exchange rate of USD = 6.79 (RMB to USD) on the interface. And the base will already save 0.15 (USD per 1 RMB).

 

These different types of rate (6.79 and 0.15) will determine the formula by which you will then calculate the amounts. You can read from the CurrencyRate table and get a rate of 0.025 and:

1) convert it to a familiar rate - 1/0.15 = 6.79.

2) either work already with 0.15, but then the calculation of the amount will be different.



So, the Rate column is virtual, but you can use CurrencyRate (exchange rate) to calculate the exchange rate.

Show all comments

Hello Community,

 

In the new Freedom UI, I need that in the dropdown field 'Responsible' (contact object) appear only the data that are of 'Type = Employee' (contact attribute).

 

I know how to do it in the previous versions but not in the new one.

In the new one I can't find the way to make this filter, can you help me?

 

Thank you very much!

Like 0

Like

1 comments

Hello Community,

I am a new bee with here and not much familiar with Creatio Studio as well. I have created a demo environment of creatio studio from downloadable. I created a new application where I am creating a list and detail page. 

The issues I am facing are:

  • The list view page shows that its continuously loading, because of which I am not able to hide or create a new column which is obvious.
  • on the Form page when I try to save my form elements/objects It is showing an error as Failed to update the structure for following schema and the schemas are my form objects which I am trying to save.
  • I found one solution on the community here that by updating the objects showing error on Workspace explorer page (System designer->advanced settings->configuration. I see my objects showing error in the status column. I did try updating the DB objects from there but showing the DB error. I think the above issue and this one is related and due to the same reason(Screen shot2)
  •  When I try to compile all in configuration, I get an error. (screenshot 3) I tried uninstalling and reinstalling the SDKs(The solution again I found here) but it doesn't seem to be working for my case.

I really Appreciate if someone could help me to figure this out.

Thanks

File attachments
Like 0

Like

1 comments

Hello,

 

I've reviewed the screenshot shared and to understand what happens with the object the actual error message from the SQL server logs should be shared. If this is MS SQL you need to take a look at the extended evens logs, if this is PostgreSQL - find the logs using this article. In the SQL server logs there will be an actual database query that fails to execute. Try executing it manually in the database and let's see which error message we face.

Show all comments