Freemarker / Netsuite - Assign a variable to a specific item amount - netsuite

I need to assign a variable to a specific item amount in Freemarker (Netsuite version) to uses in a different part of the invoice template.
I am struggling with figuring out how I can use <#assign> to do this. The item would be used only once and would go underneath the subtotal field on the invoice.
Any suggestions on how I can do this?

check the Freemarker docs
capture data:
<#assign ord_number_is>Your order number is ${record.tranid}</#assign>
${ord_number_is}
set data:
<#assign fs_6="font-size: 6pt;" />
${fs_6}

Most (all?) of the time in NetSuite transaction advanced pdf forms, the "meat" of the content for items on a transaction start with a line such as:
<table class="itemtable"><!-- start items --><#list record.item as item><#if item_index==0>
then it provides the content (usually items) in an html table and finishes the loop with a closing tag of:
</#list><!-- end items -->
When I need to first gather information from the item list but not actually print it out to the pdf, I like to follow the same structure minus the html elements. For your case, I think you want to identify a particular item in a sublist and then if it is present, record the amount for future use elsewhere in the form. Using the above structure, that would be something like this:
<!-- assign variable to hold initial value -->
<#assign item_x_amount = 0>
<!-- populate the amount if the item is present in any row -->
<#list record.item as tmpLine>
<#if (tmpLine.item == "Consulting Services")><#assign item_x_amount = item_x_amount + tmpLine.amount></#if>
</#list>
Then, later on in the code for creating the subtotal table, add in your variable lable and value. Resulting in a transaction that looks like:
Notes:
I took the liberty of expanding your request to "the sum of the amounts for a particular item". This also covers your assumption that there will only ever be one matching item on the transaction, but people rarely always follow the rules. If you definitely don't want that behavior, you can change <#assign item_x_amount = item_x_amount + tmpLine.amount> to <#assign item_x_amount = tmpLine.amount>
If the item name changes, this breaks. You did not mention how you were identifying the item in question. It is safer to use some other identifying information about the item (internal ID perhaps) or even better is a transaction line field that flags it as a row to use in this process.
I formatted the displayed result as currency using ${item_x_amount?string.currency}
Hopefully this helps! I use this technique a lot in NetSuite development.

Related

Add "vendor product code" to a QWEB report in odoo 13

In the built-in sales order report, if a product has "vendor product code" set, it will show that number in front of the product's name. If it is not set, it will show the "internal reference".
We have created a new report and would like to show the internal reference/vendor product code in a column of its own.
I am unable to figure out how to reference a specific vendor for a specific product and obtain the "vendor product code". I.E. I don't know what field from what model to use.
In pseudo-code (not qweb but you get the idea):
if(sales_order_line.vendor_product_code.is_set())
print( sales_order_line.vendor_product_code)
else
print( sales_order_line.product.internal_id)
On your custom new report on the table which contain the order-line , So you can take the idea from here which test in default odoo sale order Quotation report.
Test-Product: On the purchase tab, seller_ids have vendor set with vendor_code & default_code(internal reference) too.
Code Example,
<t t-foreach="doc.order_line" t-as="line">
<t t-set="code" t-value="line.product_id.seller_ids[0].product_code if line and line.product_id and line.product_id.seller_ids and line.product_id.seller_ids[0].product_code else line.product_id.default_code"/>
<td name="td_name"><span t-field="line.name"/><br/>Code: <span t-esc="code"/></td>
</t>
From the above code, it is just for a way to use in the report q-web, as I have used here to get the 1st seller from the multiple lists.
so do your changes as per your customization
Improved logic for Custom Requirement in Code:
<t t-set="code" t-value="line.product_id.seller_ids.filtered(
lambda x: doc.partner_id == x.name).product_code if line and line.product_id and line.product_id.seller_ids else line.product_id.default_code"/>
like this way you can check that your current partner is having the seller list.
But you can add a more precise condition so for multi-partner find in seller you can not have an error with some unique condition added as per your customization.

sorting list of items with specific field on sales order item sublist NetSuite

I like to sort the list of items in the dropdown in the standard NetSuite sublist item. Let's say items are sorted with the name when clicked on >> to open the dropdown list.
Is this possible to sort this list with any other fields, maybe a custom field on items record. let's say I add a custom field on the item record (every item), which is some numbers.
displaying that list with the order by that field.
I have seen a way around to create a custom sublist of my own requirement and then hide the standard and show the custom on a specific record by customizing the form.
I had a similar issue once, I did the following:
You can create a new body field or sublist field based on your business using userevent script(before load).
Create a search with the required order(you can do any operation to prepare your data) after that you filled the result manually to the new custom field.
Whenever the user selects a value in the custom field you set the original one to be the same as the custom one. For this one, you will need a client script.
Note: you can show your custom field and hide or disable the original field only not the whole list since the client script will be responsible to set the value to it. using this approach will not require you to add or edit any of your records which will be helpful if you have a complex process and a lot of dependencies. This approach worked for my issue I hope to be helpful to you too.

Pass parameter value to another parameter - SharePoint Designer

I have created ASPX page and have used Data view webpart on it. I am trying to filter list items based on user Logon information without domain.
I have created a parameter(LOGON) and assigned server variable LOGON_USER (this gives me username as "Domain\username")
I basically want to filter list item( On column/field called user_names in list) based on "username" only and not checking domain with it.
As while filtering, I can only set list item field to be equal to parameter. I am thinking of creating another parameter and assign the value of that parameter to be substring-after($Logon,'\') but I am not able to do that in SharePoint Designer. I was also trying it through xslt filtering but that doesn't work too as that happen after data source gets created.
Use javascript to get the user name or to trim the user name before you send it to the URL as a parameter. Then the DVWP data source can be filtered correctly.
Or, use XSLT filtering, which indeed DOES work. You just need to know where to put it. Keep in mind that with XSLT filtering the data for all users will be returned by the query and the filter will only affect the rendering.
<xsl:template name="dvt_1">
<xsl:variable name="dvt_StyleName">Table</xsl:variable>
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row[#UserName = $Logon]" />
Adjust to reflect your field names.

Sharepoint 2013 search results custom grouping display template

I am trying to implement custom grouping for search result items. I would like to group them by a managed property, but without using result blocks (query rules). The idea is to sort the results by the property and then compare the current item (ctx.CurrentItem) with the previous item using ctx.CurrentItem.ParentTableReference. If a new property value is detected we insert a new 'group header' (just some simple html). The problem is the ParentTableReference is undefined. Shouldn't there be such a property in current item object?
I'm implementing this in a custom search result item display template.
If you want get all items in result table, you can get ctx.CurrentGroup.ResultRows.

Allowing search through tags?

There is an HTML form through which a user creates an item. Items are searched using usual sql query. Now a tag field will be supplied for each item on the HTML form. So while creating an item the user will enter a tag name for the item and the item will be created along with the tag name. User will then use this tag name to search for items.
What could be the best way to implement this? Is adding a tag column to every Item table a good way of doing it? What are the other possible options?
I believe you would want to minimize round trips to a database server. Tags would likely be an attribute of one of the items of interest and it is a many to many relationship. This is a well trodden path and you can find more information here.
If you want to be able to add multiple tags, then the best way would be to implement a table like this:
item_tag
item_id - Integer
tag_name - Varchar
or two tables:
item_tag
item_id
tag_id
tags
id
name
Use the post_tag table to contain a list of which tags are associated with which item. If you want to search for items by tag, then you could do a
SELECT * FROM `items` LEFT JOIN `item_tag` ON `items`.`id` = `item_tag`.`item_id` WHERE `tag_name` = 'value'
Here is a post discussing the best way to implement a tagging system, which suggests using three tables; e.g., items, tags, items_tags

Resources