Writing the correct formula for SugarCRM - formula

I am trying to automatically populate a field through a calculated field.
Just a quick background we distribute equipment with serials numbers. This equipment is sometimes returned. So some customers have multiple products each with different status of returned, shipped and installed.
I would like to transfer this serial number to a field on the contact through a calculated field only if the status is installed or shipped.
I have tried:
related($products,"serial"),",",(related($products,"status"))
and
related(contains(status,"installed)"products,"serial")
I need this for reporting reasons and would be greatly appreciated if you could help.
Thanks

You need a combination of ifElse and equal and related and or
As an example, the following Sugar Logic formula can be placed on a Contact record and will populate the field with the related account's name if the related account is of the type "Reseller." If the Account is of some other account_type then the field takes the value of "nope!"
ifElse(equal(related($accounts,"account_type"),"Reseller"),related($accounts,"name"),"nope!")
If you wanted to add another condition, or allow for another acceptable Account Type, build in an or
When you're writing lengthy Sugar Logic like this, I find it helpful to start writing it out with indentation using a text editor:
ifElse(
or(
equal(related($accounts,"account_type"),"Reseller"),
equal(related($accounts,"account_type"),"Investor"),
),
related($accounts,"name"),
"nope!"
)
In some versions of Sugar I've had to remove the extra spacing but it seems like in 7.2.2.0 at least the editor actually allows and preservers the formatting, which is a pleasant surprise.

Related

Can I pass in a dynamic price into my typeform?

I'm trying to pass in a price into my typeform, and trying to implement a short of a payment flow with Stripe integration. The samples I have seen for this all involve static, hard-coded pricing coming from the Typeform itself; I would like to pass in the price as a hiddenfield parameter and have that be the item that is charged.
However, I am having a lot of trouble seeing examples of how to implement this. Does anyone have any guidance?
I know how to pass in parameters into the form - but how to implement the dynamic pricing based on those parameters seems to be... not possible?
Would love any input. TIA.
Typeform supports natively Stripe payments in their form. It lets you accept payments via credit card easily.
Unfortunately, if you want your price to be dynamic, you can't pass directly it as a parameter of the typeform (called Hidden field).
If your price depends on a calculation, like the number of items, you can use the calculator feature (help center article).
And ask those questions to determine the price to pay.
Here is a simple form to order pizzas at different prices depending on the type.
Here is how it was made on Typeform:
first: Setup a different price per pizza type
second: Update the total price depending on the number entered
Hope it makes sense :)

Average scroll rate in Google Studio

I want to calculate and display the average scroll depth in Data Studio from analytics.
I’m looking to get an average scroll depth in Studio. I’ve got the 10%,25%, etc scroll depth data coming in, but I now need to be able to calculate the average scroll % from this data.
To calculate the average scroll depth:
multiply the scrolled threshold by the number of events (10x500) + (20x400) + (30x475) +(40x300) + (50x200) + (60x100) +(70x75) +(80x60) + (90x20) + (100x10)
Then, take that total divided by the total number of events. 500 + 400 + 475... etc
Because I can’t reference cells in Studio I can’t get it to work. I’ve also tried Google Sheets, which does work to do the calculation, but then I can’t use Data Studios filter to provide a specific page path?
I'm thinking that perhaps the calculation will need to be done at data source, but I am not sure how to reference a 'cell'?
Data Studio doesn't work based on a concept of "cells", it works based on a concept of "fields"—which are basically properties of the data source. Similarly, you don't have "formulas" per se, but rather "calculated fields". These fields can be created either at the chart-level (single-use, but doesn't require permissions to modify the data source) or in the data source (reusable across many charts, requires permissions to modify the data source). Most fields also have an aggregation type, which tells the report how to aggregate it in charts by default (e.g. Sum or Average).
When you either edit your data source and hit "Add Field" or the option with the same name under the "Add metric" or "Add dimension" menus on a chart, you'll be presented with a box to input the formula. To access a field, just type its name (of if you're in the data source, select it from the list on the left). The editor will also typically give you an auto-complete list below your cursor based on what you're typing. Once your entry matches a field, it will get a highlight box around it (the color is based on the type; green = dimension/string,blue = metric/number). The functions available are sort of a mash-up of something between what you'd expect in Google Sheets and in a SQL query, but with more constraints on when you're allowed to use certain functions.
The documentation for calculated fields is pretty simple, so I'd recommend starting there before you try to do too much heavy-lifting in Data Studio. Because of constraints in Data Studio's data model, you'll often find that you need to create separate calculated fields for different parts of the formula, and then combine them in a new calculated field. I'll warn you that the error messages in the field editor aren't super helpful sometimes, so you may need to re-read the documentation for the functions and field types you're working with to ensure you get a valid result.
If you're running into problems, including the field names and values that you need in your calculation may help, including the source of the data (are these GA events?). The more details you give, including what you've already tried, the more helpful we can be. Also, make sure to read the docs first to make sure you have a good handle on the product you're using and the terminology the community is most likely to understand.

Drupal 8: How do I create a content reference/textarea compound field?

I have a company content type being used on a website-in-progress. Companies consist of a company name, name sorting mechanism, logo image and URL. I have a requirement to show companies taking part in different use cases in various parts of the website.
Challenge:
In the past I used a company content type for a "corporate members" list on a page, also assigning a "member level" field. But then, companies started being listed as event sponsors with specifics for what they were sponsoring, also with different membership levels in a "corporate giving club". It was messy while added/included in the old company content type. It caused confusion for content editors and developers.
Possible Solution:
In other content types, create compound fields such as "Sponsors", "Corporate members", "Donors", select lists with company entities, or sponsorship detail text areas with company entities. That may keep companies flexible and not messy (keeping company just a company).
Progress:
I found the Double field module, splitting core fields up into two separate parts. This is almost what I'm looking for, providing compound field sets. However, it won't allow references to be selected and is out of the scope of this project per this issue. I'm finding a lot of Drupal 7 examples, but not much Drupal 8 yet.
I'm starting to dig into the examples for developers module for inspiration and will post a solution unless you beat me to it. I'm also open to alternative ideas.
What is the best way to proceed? Specific code examples are not required. I would accept clues that lead me to a final working solution.
The solution turned out to be simpler than creating a custom module.
The Field Collection module allowed for the simple creation of compound fields containing any number and most (if not all) field types, including reference fields. It's also available as a Drupal 8 module (alpha at the time of writing, seems to work fine).

Is there a Drupal module to display various flags in a list of contents?

I am a PM working on a new back office for several media clients. In current back-end of my customer, they use a table (see screenshot) where the last column display some custom flags, toggled on and off according to various criterias.
For example, the red flag can mean something like "wokflow state is Ready to be published", but the blue flag can mean "created less than two days ago", and the green flag can mean "author is not a journalist but a reader"...
I never saw a Drupal interface with that sort of feature, but maybe there is an existing module who does that ?
Thanks anyway for your help !
Think that could be implemented just by using a regular taxonomy with tags (and colours associated with those tags).
If you need to toggle the flags dynamically through the interface then you might want to have a look at the flag module which allows you to do just that.

Multiple Prices for a product in ubercart?

My product is a book. Each books will be sold in 3 formats.
1) Print
2) Online
3) Print + Online
All the three prices for each book will be different.
If i add the book as different product. I have to add all the content like Index, Author details etc. 3 times for each book.
Is there any way where i can allow admin to add 3 prices for each product and user can select any one of the price?
Thanks & Regards,
Satya.
Kevin is right, but there is a problem relating to the purely hardcopy version.
You have to attach a "Feature" to the product, which is the digital asset, so that when they buy they get access to the download. I believe this is for the whole product.
So, if you're wrapping them all in one product you can only offer: Online or Online and Print.
But really there is no reason to just get the print version since it doesn't cost you anything to throw in the online version.
No, you do not need to create 3 different products, unless the SKU is different.
You can add Attributes for this product, lets call it 'Format'. You can then add 3 options to that attribute, Print, Online, Print + Online. Then when you edit the product, you can adjust the pricing for those options (ex. Print +$10).
The cost is added to the base price of the product. So, you could make the book $0, and let these options drive the cost. Example Print $35, Online $25, Print and Online $40.
There are a couple of ways you could solve this but this is how I would probably do it.
satya
You can use a default general pattern for all products while building attributes and later for each product you can override it by editing the product.
For each product you can vary the range.
You can actually set the digital portion to be attribute dependent.
Create an attribute called "Format" and give it your three options (Print, Online, Print and Online) with the appropriate price settings for each.
Add this attribute to your product.
You should see an "adjustments" subtab on the edit page for the product now, and here you can adjust the SKU depending on the Format that is selected.
On the Features tab, you can then specify the adjusted SKU's for the digital download (you may need to add the download feature twice, once for each SKU that should have it)

Resources