WHERE statement to display contacts on sidebar - kentico

I have multiple product pages (same page template), and each page is supposed to have different sales rep contacts on the sidebar. I set up the sidebar contact box as a repeater to pull data/filter data from a SalesRep page type. The SalesRep page type has a field called ContactForPage; and my plan is to put in a string from the product page URL, so that if the string match the page URL, the contact will be displayed on the sidebar for that page.
Example:
Current page url is: www.domain.com/products/product-123
John Doe has ContactForPage = product-abc
Jane Doe has ContactForPage = product-123
Jane Doe will be displayed as contact because the field value matched part of the URL.
I've been trying to write the WHERE statement but don't really know the syntax. Could you help!
Something like: WHERE: SalesRep.ContactForPage LIKE '%CurrentDocument.NodeAliasPath%'

Fist of all using URL as in SQL query is not a good idea. You have to define relation between sales reps and products correctly. Probably one sales reps might be selling TV, the other - cellphones. But if you want to directly connect product to sales man. You can use Related Pages and relationship structure.
Create new Relationship name, i.e. "is Salesman of Product" so
Page A (saleman page) will be related to Page B (product page) via the relationship above
Add related pages, i.e. for all salesmen pages add corresponding products via API or via properties > related pages
Use web RelatedPages web part to shows salesmen list on the right

I see a problem in your design. I assume a sales rep may mange multiple products, correct? If that's the case, you should add a field to the Product pagetype which allows you to select the sales rep instead of the add a field to the SalesRep pagetype, because how will you enter multiple products?
The field (e.g. SalesRepID) you add to the Product PageType can be a drop down list for select the sale rep. You can use Query to auto generate the list from the SaleRep page type. e.g. "SELECT RepID, RepName FROM custom_SalesRep". The RepID would be stored in the SalesRepID field.
For display, you can use the repeater set for SalesRep pagetype and use WHERE condition like this:
RepID = {% CurrentDocument.GetValue("SalesRepID") %}

The Relationship is working both ways. You can have multiple documents related one and vice versa, i.e. one product can be sold by many salesmen and one salesman can sell different products. You just need to define one relationship. If you have a relationship between "Product A" Page and "Salesman John" Page, you will see this relation on both pages in properties > related page.
All I am saying is this: you do not need to add extra fields to your page types (either salesman or product), you should use relationship instead.
Read here Displaying related documents.

Related

In Acumatica, using #me inside Relations Section of Generic Inquiry

We want to have a sales order dashboard where we only show orders for certain sales people based on the logged in user. For example, we have sales people BB and CR who share an assistant TP. BB can see his orders on the dashboard. CR can see his orders on the dashboard. TP can see orders for both of them on his dashboard. We also have people outside of sales who need to see all orders. We want to do all of this without having to create a bunch of custom dashboards. We wanted to maintain 2 dashboards - one filtered one for sales people and one unfiltered one for everyone else.
We have gotten close to solution by using a generic inquiry. We created custom fields on the salesperson that point back to a logged in user (UserID1 and UserID2). Multiple custom fields were used because a single sales person could be visible to 2 people. We then joined SOOrder to SalesPerson inside our GI. We then wanted to join the Users table on (SalesPerson.UserID1 = Users.PKID AND SalesPerson.UserID1 = #me) OR (SalesPerson.UserID2 = Users.PKID AND SalesPerson.UserID2 = #me). That would allow us to create a filter where Users.PKID is not null to limit the view for sales people and then not use any filter on the non-sales dashboard.
The problem is that #me is not available on the Relations section. It is only available on the conditions section. We tried to just have the join of SalesPerson.UserID1 = Users.PKID or SalesPerson.UserID2 = Users.PKID and then creating the condition for the #me portion. The issue there is that it only shows records with a match. That won't work for non-sales people.
Is there some way to include #me or an equivalent on the relations tab? Any better way to accomplish this?
Built-in variables like '#me' aren't well documented which raises questions about support of this feature.
Try this instead:
In generic inquiry TABLES tab, add table 'PX.Data.AccessInfo'.
In PARAMETERS tab, add a new parameter (ex: 'P1') and set the Schema Field value to 'Accessinfo.UserID' (use 'Accessinfo' or the alias for that table declared in TABLES tab).
In the RELATIONS tab in the join condition Child Field you can reference the '[P1]' variable.
Accessinfo DAC contains current record of the logged in user and reflects the information you see when you click your profile in the top right of Acumatica pages. If the solution doesn't work right away you can debug it with the Request Profiler page to look up the generated SQL query for the GI.

Netsuite saved search for all contacts (Prospects, Customers) and leads

I have customers and prospects as companies and a lead can be individual or company. I need to create a saved search that returns all of the contacts of prospects, contacts of customers and all of the leads in one list. I can do a contact search where status = all available statuses and I get the primary contact of customers, primary contact of prospects and all leads (individual or company) If I add contact.name to the results tab, I get all contacts of prospects and customers but I lose all of the individual leads. I'm attaching image of the criteria and results field. This setup returns the primary contacts and all leads but I need all contacts. My goal is to get a list of every contact or lead in NetSuite to send to external system.
Do a Customer search with the following criteria:
USE EXPRESSIONS = YES
Contact : Internal ID is not none Or
Is Individual is true
In your results you can use a Formula(Text) to get the proper name and/or email:
decode({isperson},'Yes',{altname},{contact.entityid})
Finally heard back from support. It turns out you can tell NetSuite to treat individuals like contacts:
When you navigate to Setup > Company > General Preferences, you have there an option to SHOW INDIVIDUALS AS CONTACTS. When this feature is enabled, individual type customer records will now show in list of Contacts
You will need two separate searches to accomplish this. One for the Leads and one for the Contacts as these are two separate Tables in NetSuite.

NetSuite: How do you delete products from a category?

Rookie NS question. I've got 1,000+ products in a category. I just created sub-categories and segmented the products better, so now all I want to do is remove the 1,000 products from the root category. How do I do that without having to do it one-at-a-time? Do I need to do a mass update?
If i'm understanding you correctly, you've already added the products to their respective sub-categories and there's just unwanted copies of the bulk of them in the root category. Usually you'd have to delete them manually.
A shortcut:
Make a temporary category
Put the subcategories under that temp category
Delete the root category. Deleting a root category will delete it's subcategories, so this is why your subcategories need to be under a different category before deleting the root.
Recreate the root category and it'll be a clean slate for you to work with. You can then simply add the subcategories back to it and delete the temp category.
I had a similar circumstance. I simply did a CSV update for Import Type: Website and Record Type: Site Category.
My CSV file had two columns, one for the internal id of the web category and one item with the value of the internal id of the item (Any random item).
Simply do the import, as an update, but the real trick is to select Update and Advanced Options below OVERWRITE SUBLISTS (tick).
In the field matching you map the internal id of the Site Category to the internal id field.
In the Site Category Presentation Items below, expand out and map the internal id of the item to item, ensuring you select internal id as the mapping option if you are in fact using this (option of Names are of course fine but I prefer always to use the Internal ID option which never changes).
Lastly select Type field for mapping and choose Item as a Default.
Example of this mapping below.
Category internal id maps to Site Category : Internal ID
Item internal id maps to Site Category Presentation Items 1 : Item
Item maps to Site Category Presentation Items 1 : Type
With the overwrite sublist selected, all the items will be removed and you will end up with just the one item in the Web Category, which you can then quickly delete if you want it completely empty.

Search and One To Many Relation in SugarCRM

I'm trying to create tag-like category field for my contacts in SugarCRM. I've read through some docs, created a module and connected it with my contacts as 1 to N relation. The problem is, that Edit Form allows to choose only one category, but then you can add as many as you want in Contact View.
But when you search, it only finds contact that have category set in edit form, but does not pay attention to other categories set in list.
What is the correct way to create 1 to N relation so all of the items would be used in search results?
thanks in advance,
Michael
You should be able to use a MultiSelect field for the tagging and it pick up correctly during searches.

Dynamic columns based on rows

What I am doing might be really stupid, if so, please correct me, but I am trying to do the following thing:
I want to have a list with (for example) the following items:
List Addresses
-Name
-Address
-City
-Country
But, based on their Country, I want to display different columns that I want to record in a List. For instance:
CountryColumns
(United States - SSN - Yes)
(United States - State - Yes)
(United States - Province - No)
(United Kingdom - SSN - No)
(United Kingdom - State - No)
(United Kingdom - Province - Yes)
And then when the user picks United States in the country list, the next time the user edits his information, certain columns will be shown. (It's also possible that all will be shown, and that the next time the columns with No will be hidden).
I've looked at ways to do this, and I only found out that Infopath is able to do this. But, that'd mean I would have to create a different view for every country, and show / hide certain columns. It seems like that is a bit of overkill.
Anyone knows a way how to do this?
Greetings,
Mats
Here are three options:
Custom content types. This is probably the most SharePoint-y way to do it. You can create a content type for each Country and then control which fields are included in that content type. The obvious downsides to this are that you could end up creating a lot of content types and also that selecting a content type (especially when creating a new item) is not the same as selecting a choice from a dropdown list.
Javascript/jQuery. Either by changing your master page or by adding a Content Editor Web Part to your Edit Form, you could use javascript to hide certain fields based on the selected value of Country.
Custom fields. This is the most involved, but instead of having the SSN field be a regular Single Line of Text field, you could create a custom field that inherits from SPFieldText and then manages its render visibility based on the selected value of Country.
There are four ways you could modify SharePoint to do this that come to mind.
Have a list address content type and then a separate content type for each country that requires extra fields. Use a webpart to enter data to the list using the correct country's content type.
Same as above but instead of entering data through a web part, you can add the data into the list using the base address content type. Use an item adding event receiver to decide which content type to add the data to.
Use one super content type that includes all fields but with custom list view pages to filter the fields based on the county value.
Use infopath with either separate views for each country or a section for each special field with a condition to hide it if the required country isn't selected.
Personally I would recommend 4. It's the simplest and quickest to implement.
You cannot do this out of the box.

Resources