NetSuite formula to show quantity ordred on first order - netsuite

We have a saved search in place that displays date of first order and last order by customer & item within a given date range. For example - Looking at sales for May 2022 - today, it shows the item, the customer, the date they first ordered the item, and the date they last ordered the item.
I am now also trying to incorporate the quantity ordered on the first order.
crietera
results
I've tried the following, but keep getting an invalid expression. Can anyone advise on how I might be able to display the qty on the date of the first order?
MIN(CASE WHEN {custbody_reporting_ship_date} THEN {quantity} END)
and
CASE WHEN (MIN({custbody_reporting_ship_date})THEN {quantity} END)

I think this can't be achieved in saved search via simple formula. You may want to try below, what I will do is try to record the first and last order id in the customer record, then from customer saved search you can source from these order fields to the order details.
Create 2 custom entity fields applied to customer
first order id => Type:List/Record => List/Record:Transaction
last order id => Type:List/Record => List/Record:Transaction
Create 1 saved search to get the first order id per customer
Similar to the one that you created, the result field just need the customer internal id and min(document number) and filter need to add customer.internal id
Create 1 saved search to get the last order id per customer
Similar to the one that you created, the result field just need the customer internal id and max(document number) and filter need to add customer.internal id
Create 2 scheduled workflows, to update the first order id and last order id fields in respective customer record.
Create your first and last order customer Saved Searches using the 2 custom fields to source for the order details.
Not sure if this help.

Related

How to create a number field with prefix (ex: 00001) that increments whenever a document is added in SharePoint Online?

I created a calculated column and concatenated the id with a prefix, but it didn't work as expected.
The reason was that whenever i upload a file, the formula in calculated field that contains the ID with the prefix is executed, then SharePoint creates the ID.
So, the ID is being calculated as empty and only the prefix is showing.
What I used:
=CONCATENATE(REPT("0",MAX(0,5-LEN(ID))),ID)
What i would like to create is a number field with a prefix (ex: 00001) that increments whenever a document is added in SharePoint Online.
In other words, it's like the ID column in a list but with a prefix of five digits.
Therefore, is there any solution for this problem?
Thank you 😁.
Using the calculate column formula, when creating an new item, the ID column and the calculate column are created at the same time, so the value of the ID column cannot be obtained, so the calculate column will be displayed as 0.
But you can solve this problem by creating a flow.
Please refer to the screenshot below:

Using groupsVariable in COLLECT to track unique values

I'm using the following AQL to track unique visitors by month and year. Each hit contains a datetime stamp, _date, and a user name, user.
FOR hit IN PageHits
COLLECT month = DATE_MONTH(hit._date),year=DATE_YEAR(hit._date) INTO user=hit.user
SORT year,month
RETURN {month,year,uniqueVisitors:LENGTH(UNIQUE(user))}
The query calculates the correct answer but it strikes me as inefficient because the variable user contains many duplicates. The final LENGTH/UNIQUE removes these and returns the number of unique visitors.
I looked at AGGREGATE but all of the operations are statistical.
So, is there any way to add only distinct/unique values into the group variable user?

Find each customer's second order date in a list of all orders

I have a list of all orders placed in a time range and I am trying to calculate the difference between each customer's first and second order. I have a list of unique customer IDs on another tab and I already have the first order date for each. I need a way to grab the date of the second order, corresponding to each customer ID.
In the sample data below, the correct output of this formula for customer ID "153950" would be "5/11/17 8:41".
Use AGGREGATE()
=AGGREGATE(15,6,Sheet1!C1:C4/(Sheet1!A1:A4 = 153950),2)
The ,2 is grabbing the second smallest date.

Duplicate results in NetSuite Contact search

Can someone help me understand why I get duplicate results on a Contact search in NetSuite only when I include a Customer field as a result column? Below are steps for how I am reproducing this problem.
Create a new Contact search
Add a single criterion: Internal ID is any of 230, 597, 1808
For results, return just a single column, Internal ID
Submit the search. 3 results are returned as expected (screenshot below).
Return to the criteria for the search
For results, add a second column, Customer : Internal ID
Submit the search again. This time six (6) results are returned (screenshot below).
What is incredible to me is not only are there double the number of results, but the results actually appear to be unique based on the fact that the Customer : Internal ID values are different. What causes this behavior?
It depends upon the field you give as result. If you many number of field in the result section, each result field that match your search criteria or filter will be shown irrespective of what is already displayed(ie,duplicates will be shown).
Use criteria to filter it out or reduce the result field
This is a similar interaction to the "main line" criteria on a transaction search. a contact is a record in itself. When searching for a contact it returns a singular one. As soon as you tell it to return an internal ID of a related document or customer you will find that sometimes a contact can exist in two places at once. So your second set of results basically says that (for example) Contact 597 is connected to customer 168 and customer 167. Contact records are not the same as a customer record.
Each contact has its own internal id, however, the same contact might show up to different records because NetSuite allows you to attach a contact to more than one customers/sub-customers. Therefore when you add customer: internal id it's pulling out all the customers that have the same contact on their records. You can add another column that shows the customer name/id under results and see if this is what happened.

Deleting items based on another list column

I have two list
1. Resgined Employee IDs
2. Employee details (It has Employee ID)
Is ther any way I can compare the column and delete resigned ps numbers records from Employee details list.
Is it possible without using code/programming?
Yes, you need to add column from Resigned Employee Id as a lookup column to Employee details.Then you can filter all records that have this column not empty and delete them.
You could use a workflow, running on the 1 list, have it trigger on item change (for example if position changed to resigned) to delete the item with lookupId equivalent to current items id.

Resources