Время создания
Filters

Hi Community,

I want to run a function only if the SaveRecordRequest is true. I tried to run await next.handle(request), but it returns undefined even if the record is save is successfully. Here is my code and test result:

 

 

			{
				request: "crt.SaveRecordRequest",
				handler: async (request, next) => {
					const saveResult = await next.handle(request);
					if(saveResult) {
						const id = await request.$context.Id;
						const files = await request.$context.SPJFile;
						await carPooling.uploadSPJ(id, files);
						request.$context.SPJFile = null;
					}
 
					return saveResult;
				}
			},
Like 0

Like

1 comments
Show all comments

Hello creatio experts, 

 

I want to show/ hide printables based on currency field. If the currency is us then show the printable which names contains '-US' in them. I have tried follow this article but the field value is getting undefined as the time this function run entity might not be initialized. I mainly want to do this for edit page.  

 

My code: 

 

initCardPrintForms: function() {

this.callParent(arguments);

var printMenuItems = this.get(this.moduleCardPrintFormsCollectionName);

if (Ext.isEmpty(printMenuItems)) return;

 

printMenuItems.each(function(item) {

                               item.set("Visible", {bindTo: "getPrintMenuItemVisible"}); 

}, this);

},

 

getPrintMenuItemVisible: function(reportId) {

var type = this.get("UsrCurrency") || { displayValue: "" },

console.log("## UsrCurrency", UsrCurrency);

var printMenuItems = this.get(this.moduleCardPrintFormsCollectionName),

item = printMenuItems.find(reportId);

if (Ext.isEmpty(item)) {

return false; // Ensure a boolean return

}                                

                                 var caption = item.get("Caption") || "";

 

return type.displayValue === "US Dollar" ? caption.includes("-US") : true;

},

 

Alternatively, I have tried this but printforms and currency come undefined

 

 

        preparePrintFormsMenuCollection: function(printForms) {

           printForms.eachKey(function (key, item) {

               if (!item.get("Caption")) {

                   item.set("Caption", item.get("NonLocalizedCaption"));

               }

               item.set("Tag", key);

               if (item.get("TypeColumnValue")) {

                   item.set("Visible", { bindTo: "getPrintMenuItemVisible" });

               }

               var currentCurrency = this.get("UsrCurrency");

               console.log("## currentCurrency1", currentCurrency);

               var isCurrencyEmpty = Ext.isEmpty(currentCurrency);

               var currentCurrencyDisplayValue = isCurrencyEmpty ? "" : currentCurrency.displayValue || "";

               if (!isCurrencyEmpty && currentCurrencyDisplayValue=="US Dollar" && item.get("Caption").includes("-US")){

               item.set("Visible", true);

               }

               else {

               item.set("Visible", false);

               }

           

           }, this);

       },

 

We already have getModulePrintFormsESQ() on the edit page and if add filter there for currency it would hide the remaining printable in list but this function only responsible for creating query so this doesn't refresh the list of printables as value of currency is undefined at the first call.

Like 0

Like

0 comments
Show all comments

Hi first post and on my journey to developing in Creatio 8.2 

I been reading a lot on the forums but i maybe confused with some of the information out there.  I been trying to write a simple reusable class to simple return a name from a lookup.  I have a guid id.  I been trying to use ExecuteScalar, but should I be using Execute? I have attempted both ways but no matter which way I get CS1061 missing assembly reference.  I'm not sure if its because its not available in this version builder or just something I missed.  I would appreciate any help 

Like 0

Like

3 comments
Best reply

You can see an example of that here, which uses the Select class to read the value: https://customerfx.com/article/reusable-function-for-retrieving-the-id-of-a-lookup-item-from-its-name-in-bpmonline/

The approach in the article above would work for anything that inherits from BaseLookup since it would always have a "Name" column, however, would fail for anything that inherits from BaseEntity (since it's name might be something like "UsrName" instead of just "Name"). A better approach would be to use the Entity class to get it's primary display value - something like this: 

// using Terrasoft.Core.Entities;
public string GetRecordDisplayValue(string entityType, Guid id)
{
	var schema = UserConnection.EntitySchemaManager.GetInstanceByName(entityType);
	var entity = schema.CreateEntity(UserConnection);
	if (entity.FetchFromDB(id))
	{
		return entity.PrimaryDisplayColumnValue;
	}
	return string.Empty;
}

The usage would look like: 

var cityName = GetRecordDisplayValue("City", cityId);
// or
var accountName = GetRecordDisplayValue("Account", accId);
// or
var customName = GetRecordDisplayValue("UsrCustom", someId);

Ryan

Hello,
 

Do I understand correctly that your task is to return the name of the lookup from the Lookup table, having the lookup ID in the table?

Lookup table

If not, could you explain your business task in more detail? Perhaps a screenshot or code snippet will give us a better understanding of the task.

Also, if you encounter the CS1601 error during your implementation wit Execute, ExecuteScalar methods, please check out this documentation on Creatio Academy if your code follows the recommendations in the article - https://academy.creatio.com/docs/8.x/dev/development-on-creatio-platfor…;
 

Thank you.

You can see an example of that here, which uses the Select class to read the value: https://customerfx.com/article/reusable-function-for-retrieving-the-id-of-a-lookup-item-from-its-name-in-bpmonline/

The approach in the article above would work for anything that inherits from BaseLookup since it would always have a "Name" column, however, would fail for anything that inherits from BaseEntity (since it's name might be something like "UsrName" instead of just "Name"). A better approach would be to use the Entity class to get it's primary display value - something like this: 

// using Terrasoft.Core.Entities;
public string GetRecordDisplayValue(string entityType, Guid id)
{
	var schema = UserConnection.EntitySchemaManager.GetInstanceByName(entityType);
	var entity = schema.CreateEntity(UserConnection);
	if (entity.FetchFromDB(id))
	{
		return entity.PrimaryDisplayColumnValue;
	}
	return string.Empty;
}

The usage would look like: 

var cityName = GetRecordDisplayValue("City", cityId);
// or
var accountName = GetRecordDisplayValue("Account", accId);
// or
var customName = GetRecordDisplayValue("UsrCustom", someId);

Ryan

Ryan Farley,

Thanks!!  By reading your comment and supplied link I have a better understanding how to attack future problems. :) 

Show all comments

Hello Community,

I want to remove "New Contact" from the contact name (e.g., New Contact (email address)).

I tried using a business process that runs when a new record is added to an activity. It retrieves the name from the "From" field (name ). However, since the contact field in the activity is empty, I cannot access other contact details.

To work around this, I used a timer signal with a 5-second delay, which worked. However, the issue now is that the case registration email is sent before the business process updates the contact name. I also tried delaying the case registration email, but when I do, it is not sent at all.

Is there another way to update the contact name?

Additionally, why is the email delay not working?

 

Like 0

Like

0 comments
Show all comments

Hello Community, 

We have a button in Freedom UI that calls a Business Process.

We want this button to be disabled at least for several seconds, till the process is completed. Clicking the button again, while the BP is still running might bring several issues to our logic.

(Printscreen: Button calling BP)

How can this be achieved?

Regards,Sasor

Like 1

Like

3 comments

Interesting idea :)

We could do with this.  I think I may have implemented this in the past by disabling the button on calling the process, and using the Send Message element at the end of the business process to publish a message that the client module is subscribed to to re-enable the button.

Hello community,

Is there any other way besides the Backend-Frontend websocket (which I havent tried yet)?

Sasori

Show all comments