Preselect drop down list when a value selected in sugarCRM - drop-down-menu

I have two drop down lists, lets say: "Job Types" and "Person in charge".
When users choose a "Job type" it will preselect the "Person in charge".
Example:
Job Types:
Finance
Computer
Sundry
Person in charge:
Alice
Bob
Celion
David
Eason
When i choose "Finance", "David" will be pre-selected.
When i choose "Computer", "Celion" will be pre-selected.
...
How to customize this in SugarCRM? in Logic hook? or metadata?
Thanks.

If you have access to SugarCRM Professional's Sugar Logic, you might start here: http://www.profilingsolutions.com/archive/dropdowns-using-sugarlogic-formul/
This article uses a logic statement like related($accounts,"account_type") but you could write out a series of equal/if/then statements to check fieldA for various values.
More on Sugar Logic: http://support.sugarcrm.com/02_Documentation/01_Sugar_Editions/04_Sugar_Professional/Sugar_Professional_6.7/Administration_Guide/07_Developer_Tools/01_Studio#Using_Sugar_Logic
If you are using SugarCRM CE, you won't have access to Sugar Logic. In that case, I find the easiest thing to do is adjust the module's editviewdefs to include custom JavaScript that monitors the field(s) and sets the values. Check /modules/Notes/metadata/editviewdefs.php for an example on including JavaScript in your edit view metadata.
One more caveat: if you were to use Sugar via it's API, it will ignore any thing you do to the UI view. You'll need to do this within a Logic Hook as well to enforce it throughout the system.

Related

Customize ATG promotions so "highest priced item" considers sale price if there is one

I need to customize ATG promotions applied to "highest priced item" but that it considers when there is a sale price and uses it rather than the default list price.
Based on what I read from atg.ui.commerce.pricing.DescriptionBuilder.java when configuring the "Condition and offer" in BCC to generate the PMDL rule when marking the option:
"Highest priced item first" under "Apply Discount To" it generates a PDML rule with this section:
<up-to-and-including number="1" sort-by="priceInfo.listPrice" sort-order="descending">
But as you can see ATG always uses priceInfo.listPrice hardcoded within the PDML rule.
How could I do so my promotion is intelligent enough to detect when an item has sale price so it uses it rather than the list price?
Sorry for my delay to reply your answer, It took long since I started digging into it and I want to share my findings:
In my company we implemented a sale list price based on ATG suggestion; it means on atg/commerce/pricing/ItemPriceInfo we'll populate listPrice from "List Price" list and salePrice from "Sale Price" list.
Across the site in order to display an item price we have to chose in between both lists by applying next logic to give priority to sale price:
isOnSale() && getSalePrice() < getListPrice ? getSalePrice() : getListPrice();
The problem comes when creating a new promotion on BCC and picked the option to apply the promotion to highest (or lowest) priced item since BCC by default will add in the PDML rules a XML tag like:
< up-to-and-including number="1" sort-by="priceInfo.listPrice" sort-order="descending" >
As you may notice, the trick the PDML does is to sort all items based on "priceInfo.listPrice" and then pick the first.
When the PDML is evaluated, ATG maps this XML tag by an instance of atg/commerce/pricing/definition/UpToAndIncludingElem; there the method "evaluate" will call the method "resolveCollectionList" living in atg/commerce/pricing.definition.CompoundPricingModelExpression which at the end ends up calling the method "sortList" of the same class.
This is a hacky approach worked for me but I already dropped:
5.a I decompiled UpToAndIncludingElem.class and added its own version of the method sortList, since this method receives a parameter "sortBy" I added a condition so if its value is "priceInfo.listPrice" I changed it to acustom new attribute "priceInfo.finalPrice"
5.b Since we had already extended atg/commerce/pricing/ItemPriceInfo class I added a new attribute called "finalPrice" with its setter and a custom getter which evaluates if there is a sale price to use as I explained in step #2
Now every time a promotion with that XML tag within the PDML rules to apply the promotion to highest (or lowest) priced item, my custom UpToAndIncludingElem's sortList method will replace the sortBy parameter to use "priceInfo.finalPrice" which getter method will consider sale price.
Why am I dropping this approach?
Because the way I overrode the class relies on order classes are added to the project within the class path and feels risky to me
I used a decompiling tool which I can't guarantee is the optimal JAVA code
If later with another ATG version this flow changes I may run into trouble
What am I going to do?
I'll keep the definition of "priceInfo.finalPrice" I added on our custom class from ItemPriceInfo class
I'll look how I can change the promotion template so hardcodes my custom attribute "priceInfo.finalPrice" rather than "priceInfo.listPrice"
Thanks to people who has taken the time to read and reply my question and I hope my discovery and approach could work to you.
Of course feel confident to ask or suggest things.

Drupal 7: Combining multiple content type in single view

I have a content type called Author which is referred in another two content types called Novel and Book via Node Reference Module.So we can add author entity to both Book and Novel content types.
Both Novel and Book contain another field called Release Date.
Now I want to show a block which will display the name of book and name of novel in chronological order based upon the release date when user come to that corresponding Author Page.
Ex. Suppose A is an author who is author of BookA(Release Yr-2006), NovelB(Release Yr-2004),BookC(Release Year-2009). When user come to Author A page then he will be shown a block which will show the Books/Albums in chronological order like this:-
NovelB--BookA--BookC
Please suggest as how to achieve in Drupal 7.
You want to display the following field title (I assume the book name is the node title)
For the sorting you can use the sort option in views, it is pretty self-explaining. Choose the name of your release date field.
For the connection between author and books you will have to use a contextual filter (advanced).
Add the author-reference-field from your book/novel (the field you use to refer to the author). Then choose to use a default value (2nd option) and choose content id from url. Now your block will find all nodes that refer to the page with the current page-id. Since we chose to display the title fields, you should see a list.
Note that live preview does not work here, so you will have to go to the actual page to see the result.
UPDATE:
This works when you have re-used the same field for both content types. If you have uses more then one field you will have to use an OR operator to make the contextual filter work. Thanks to d34dman the following page was given to do just that.
Although for new implementations I would recommend using the same field (eg. reference_to_author) for all references from all content types.
Yah..I am able to solve this problem by adding custom code. I have used hook_views_query_alter method and then added join relationship and where clause as per requirement. Please refer to following article for more clarity..
http://www.midwesternmac.com/blogs/jeff-geerling/filtersearch-multiple-fields
Thanks for posting the reply and keeping my hope alive.

Can't add Subject text to Regarding field in Dynamics CRM Activity

I've added several Subjects under the Admin section of Dynamics CRM. I'd really like to add one of these "Subjects" to the Regarding field within an Activity. E.g. someone called, and it was related to "ProductX".
Strangely, the entity type "Subject" does not appear when trying to select an item for the field. A range of other entity types such as "Contacts" and "Accounts" appear.
Does anyone know why Subjects can't be selected here? I would have expected this was OOB functionality.
That because it doesn’t really make sense to have activities regarding a subject.
An activity only really makes sense in the context of something else, and that something else is generally a real thing in the world or a piece of work. The Regarding field really says: "This Activity involves working on this thing".
For example, if John Smith rings your company, it makes sense to create a new Phone Call activity that Regards the Contact record of John Smith. With this approach you can see the entire activity history against a Contact. By making the Phone Call regard the Contact you are saying this piece of work is about the Contact.
If the Phone Call was Regarding a Subject, it would be saying, "This Phone Call involves working on the Subject", which isn’t true, its work about the Contact. Also you lose the ability to track correspondence with the contact.
So my suggestion would be, use the Regarding field to link to people and things, and add a relationship between your activities and subject if you want to classify your phone calls.
As a side, there is a product entity in CRM (it can’t be Regarding however), so perhaps you should create a relationship to that.

Magento View 'Company Name' Instead Of First/Last Name

Can Magento view/manage our customers by their business name in addition to their contact names to find them easily? It is being used for B2B, so when emails go out they are pulling the customer’s name, instead of the company name which is more appropriate.
Is this a global setting?
thanks in advance.
Magento stores business name on the customer's address by default, so it's a little harder to get to.
There's no reason you cannot add another customer field to put the company name on the customer record itself. That way you'll have no problem accessing it, and can change other screens in the system to reflect it.
If you don't want to go to those lengths, you could always implement a method that pulls the company name from the default address, and save it into the session by default, for easier retrieval.
EDIT: Better idea.
Looking through the sales email templates, there are two methods that are used to grab a customer's name:
$order->getCustomerName();
$order->getBillingAddress()->getName();
I don't see any separate references to the company name, so you should be able to substitute these two methods for your own and get the desired outcome. You'll need to create your own module and override the models for customer/address and sales/order (others have covered this in depth elsewhere). Then create methods that look something like this:
public function getCustomerName() {
if($this->getBillingAddress()->getCompany()) {
return $this->getBillingAddress()->getCompany();
}
return parent::getCustomerName();
}
That's the example for sales order, modify accordingly for customer. Now your company names will be used whenever available, and when they aren't the fallback will be to the original implementation (customer name).
Hope that helps!
Thanks,
Joe
You are correct about the universal application. If you did want just the emails, the concern is whether you have access to your custom function where you need it. If there's no object handy, I'm not positive that you will be able to call just any method that you need to.
An approach that would work in this case would be to override the two objects mentioned below, but to instead add a getCompanyName method to them. That way, you'll have the right objects to call, and you can edit the emails specifically to taste.

Model for localizable attribute values in Core Data Entity?

If I want to create a entity in Core Data that has attributes with values that should be localizable I'm wondering how the most efficient way would look like?
As a example let's assume the following structure:
Book
name (localizable)
description (localizable)
author
An localized book entry would look like this:
name: "A great novel" (en/international),
"Ein großartiger Roman" (de),
"Un grand roman" (fr)
description:
"Great!" (en/international),
"Großartig!" (de),
"Grand!" (fr)
author: "John Smith"
In a SQL/SQLite implementation I would use two tables. A books table containing the book information (author, the english/international name and description) and the localizationBooks table that is related using the primary key of the corresponding book. This second table contains the localized name and description values as well as the languageCode. This would allow to have a scalable number of localizations.
For fetching the data I would use a
SELECT COALESCE(localizationBooks.name, books.name)
to get the actual values for the given language code. This allows to use the international english value as fallback for unsupported languages.
Would this require a separate entity in Core Data (e.g. BookLocalization) that has a relation to the Book or is there another recommended way of doing this?
The strategy you mention is usually the best. As you suggest, this requires an extra entity for the localized properties.
You can then write a helper method on your Books entity to get the appropriate localization object for a given language and use it like this:
[book bookLocalizationForLanguage:#"de"].name
You could even take it a step further and just add properties like localizedName, localizedDescription on the Books entity which will fetch the appropriate localized value.
Well, despite that this topic is 3 years old... I just stumbled upon it, asking my self the very same as the original poster. I found another thread with an answer.
I'll just repeat it in here in case somebody else hits this thread (Answer from Gordon Hughes):
Good practices for multiple language data in Core Data
To summarize:
Let's say you have Entity Books. Then you will have to make an additional one, called Localizedbook for example. In Books you have the attribute "title" and in LocalizedBook you have "localizedTitle" and "locale" for international strings like "en_US".
You now have to set the relationship between title -> localizedTitle (one to many, as one original title can have multiple translations).
So, every time you fetch "title" you will get the "localizedTitle" given to a specific locale, if the relations are set correctly.

Resources