SuiteScript - Create a popup link on a Purchase Order Line - netsuite

I'm looking for a method to create a "popup" window link at transaction line level to display a list of sub-records, almost identical in nature to the Inventory Detail popup, but it would be a custom suitelet form.
So, basically I want to have a clickable line in VIEW and EDIT modes, where the user clicks on a hyperlink which will open a popup and display a list of ASN subrecords linked to the specific Purchase Order line.
There is a 1-many relationship between each PO line and ASN records.
I would envisage the "link" for each line would be a counter of the number of linked subrecords, and if zero, the link would be disabled.

Make a Suitelet that you call from its deployment.
Make a sublist field on the record type you're looking to put the popup link on.
Make a client script that is pointing to the record type you're looking to put the popup link on. In this script, hook into the line level sublist, and use something like <href> and/or <a> HTML tags to format the link in the sublist field you made in step two. You'll want to create the popup by specifying relevant parameters in window.open(parameters)

Related

How to create a NotesRichtext item that is computed for display?

I know this is a common problem, and I tried a few solutions already, but the problem I have right now with my current code is that even though the attachments show in the computed for display field, I get the error "Note Item not Found" when I try to open them.
The form is built with two fields, in a programmable table that displays the editable one or the computed for display one.
The trick I found with Google's help was to delete the computed for display item in the queryopen event, so Notes regenerates the cfd item when opening the document. Visually, this works, as I see the text and attachments, but the attachments can't be opened.
Here is the code that removes the item in the QueryOpen of the form:
...
Set item = doc.GetFirstItem("dspDescription")
If Not item Is Nothing Then Call item.Remove()
...
Has anyone successfully achieved that functionality? Is there another way of doing this? I already tried with subforms, and because of the way the application is built, I need to be able to switch from editable to read only on the flick of a radio button, so subforms are out of the question as they can't be displayed dynamically.
Why don't you simple put the richtext item in a controlled access section and make that section editable / not editable with a computed for display formula. Select "always expand" and hide the section title, so that nobody can collapse it, et voila.
Regarding your comment: With this properties:
for this section in designer:
You get this result:
You see: No twisty, no "visible" section

Hide standard Edit/Remove button in Netsuite - How can i hide default netsuite buttons (Edit, Remove) from list

Hi fellow netsuite gurus,
My custom page hosts a parent record and in it i have a item sub list in a Child record. The problem happens when user tries to edit the line items by clicking on standard edit/remove buttons available on line items in edit mode. I have tried unchecking "Allow child record edit" and "Show Remove" options in the child record settings. but for logical reasons in our program, we cannot uncheck these options. So now the question is:
Has anyone figured out how to hide these buttons using client side code or any other setup feature?
Here's a suggestion:
Edit the record:
In Child Records subtab, do not select a tab for the child records to hide it
Create a saved search:
Check AVAILABLE AS SUBLIST VIEW.
In Results subtab, set OUTPUT TYPE as Result.
In Available Filters subtab, add the child record's field link to the parent record.
Edit the record, add the search as sublist view.
View the record and check the list, there should be no edit nor remove links.

How can i upload/use my client script in suitescript NetSuite

Can somebody explain to my how can i use or upload my client script in suitescript creating a form in netsuite? Appreciate the help. Thank you.
Your question is not clear. You want to upload a client script that would create a form?
First, do you want to upload javascript/suitescript file? if yes then you should follow what Jo O posted earlier.
Second, you mean your client script will create form? I don't think it is possible because only suitelet can create a form.
Third, you mean to say that you want a client script attached to a form? If yes there are two ways to do it, First you can customize your form and put your client script on the Custom Code tab. Second is to create a client script record and do not deploy it to any record take note of the script ID and you can use the setScript method to set/attach the script on the nlobjForm object on before record load of user event script or on the suitelet.
This is from SuiteAnswers # 23388.
Assuming you're using the Eclipse IDE with the SuiteScript Add-in, first make sure that you have your NetSuite accounts setup in the IDE:
1.In SuiteCloud IDE, set your master password by going to NetSuite > Master Password > Set Master Password.
2.Add your NetSuite accounts by going to NetSuite > Accounts and clicking Add.
After you have the script file ready:
3.Next, right-click in the SuiteCloud IDE editor area and then go to NetSuite > Upload File in Editor. The Upload File in Editor window opens. Wait for the progress bar to complete. The Upload File in Editor window closes upon completion.
Verify Your Script Upload
4.Right-click in the editor area and then go to NetSuite > Log in to Project Account. A browser loads with your NetSuite account logged in.
5.In NetSuite, go to Documents > Files > File Cabinet. The File Cabinet Folders page of your NetSuite account loads.
6.Navigate to the SuiteScripts directory and check your file in the subdirectory that matches your project name.
You then need to create a custom form that will link in this code.
7.In NetSuite, go to Customization > Scripting > Scripts > New. The Select Type page loads.
8.In the Type list, click Suitelet. (assuming your code is a suitelet)
9.In the Name field, enter a valid name (example: GettingStarted_SS_HelloWorld).
10.In the ID field, enter a name that begins with an underscore (example: _gs_ss_helloworld).
11.In the Scripts subtab, select your *.js file in the Script File dropdown list.
12.In the Function field, enter the function name that you wrote. Use the exact case and do not use the parentheses.
13.Hover over the dropdown arrow on the Save button, and then click Save and Deploy. The New Script Deployment page loads.
14.In the Title field, enter the Name value from step 9.
15.In the ID field, enter the ID value from step 10.
16.In the Status dropdown list, select Testing.
17.Click the Links subtab.
18.In the Center dropdown list, select Classic Center (or whichever Center is appropriate).
19.In the Section dropdown list, select the menu where you want this to appear (example: Setup).
20.In the Category dropdown list, select the submenu on the menu where you want this to appear (example: Custom).
21.In the Label field, enter the exact item on the menu that you want the user to select (example: Getting Started).
22.Click Add.
23.Click Save.
Test Your Script
24.In NetSuite, go to the menu, submenu, and item specified in steps 19, 20, and 20 (example: Setup > Custom > Getting Started). The page you just created should load.
You should create a Suitelet with a form and then create url using N/url and open it using https or nlExtOpenWindow from client side.

Browser add on/extension to intercept data selection then simulate link click and data entry

Background: a third party web application with a requirement on the order page to explicitly guide staff when a certain category of product is ordered.
Normal process:
select product to add order line (click on product image)
New process:
select product to add order line (click on product image)
[add on] simulate click on edit order line
[add on] simulate clear of default additional information form fields
enter additional information and click save
Note that the two steps to be performed by the add-on could be performed by the user however when things get busy or new staff begin is often the case that the order gets processed with the default value.
Any pointers in the right direction would be appreciated.
A multi-browser solution is preferred but not essential.
I am an experienced developer, including web development, but have no experience in browser add on/extension development.
Thanks.
You can make an addon out of this very easily. You addEventListener to the gBrowser and if the event.target is the product element then preventDefault so the click doesnt go thru (you will have to do mousedown and mouseup prevent as well). Then rather get the id of the "edit order line" and do .click() if that doesnt work and you really need to simulate use MouseEvent:
MDN :: MouseEvent
MDN :: Initatite/Dispatch MouseEvent
To enter aditional information get the id of the fields, and set their value. Then get the "Save" button id and then do .submit() or .click()
i said do get id in this post but you can use querySelector and go by css selector
see this page here on how to interact with content in currently selected tab:
https://developer.mozilla.org/en-US/Add-ons/Code_snippets/Tabbed_browser
basically just do gBrowser.contentDocument.getElementById

Automatically open document when only one document is listed in repeat control

I have a repeat control for a domino view which displays the results from a search field.
As you type more characters into the search field the number of items in the list is reduced. If/When the the list only contains a single item I would like to open item automatically, without having to click the link.
Any ideas are appreciated.
Edit: after some very interesting responses, here are some screenshots
I have 3 elements on the page, a searchbar, a repeat control and a form:
When I start typing in the search bar, the repeat is refreshed with every keystroke:
the list is reduced, typing the next character ...
again the list is reduced, only 2 left, typing again....
Only one left, now it would be time to open the document in the form ..... without clicking the link.
I've tried several events on the page, but it seems that I could not find the one that will allow me to "select" the document and display the data in the form.
It seems that it's not as simple as I thought
Since you want to open the link automatically I don't know if I would try to base it on the getRowCount() of the repeat itself. You don't want to even get that far right? you just want to go to the single document.
I would put a function in beforePageLoad event maybe. Not totally sure which event but I'd try that first. Use SSJS and do a lookup that would basically return a collection of what the repeat would show. If the collection count = 1 then get your destination from that entry and do your redirection from there.
That what I would try at least. Interesting scenario!
Now that I see the screenshots this might be easier then you think and I have already implemented something similar on an internal application that I have built. It does rely on the fact that each entry in the list is 100% unique.
First of all you will need to bind the search field to a scoped variable and the onchange/onkeypress event will need to perform a partial refresh of a panel that contains both the list and the document portion of the page.
For the list the link on each item should set the value of the same scoped variable used in the search box and clicking the link should be set to run a partial refresh of the document area.
For the document area you will need two panels, the first panel will only display if there is no matching document and the second panel will only display if there is a matching document, you can do this in the rendered section by writing some ssjs that grabs a handle to the db/view and does a dblookup and returns either true or false if the document exists depending on panel your dealing with.
With this setup, when somebody clicks a link or fills out the searchbox the scoped variable will contain a value, the document panels will then check to see if this is a unique value in the view in the db and update themselves to either display the 'no document' panel or the 'document' panel accordingly.
You could add a evaluation script to the entry of your repeat control which checks the size of your repeat control using the method getRowCount() from the component. If this is 1 you could execute a context.redirectToPage("yourpage.xsp?id=yourid",true) this forces the current page to send a redirect request back to the browser and therefore redirects you to the correct page.
All you need to know is which xpage you need to open and which parameters you should use. But these could be retrieved from the content you are iterating over.

Resources