Hi, how do I customize a saved search using suites...
# suitescript
b
Hi, how do I customize a saved search using suitescript? I need to get input from the user as filters and show the results. I need to use suitescript as I want to pull more results based on the filters provided by the user. It needs to be in the UI so user can easily access it.
c
So just a regular saved search? Seems kinda silly to do all that work to create something custom when a saved search will let the users do this.
Otherwise, you'd need a suitelet that has the fields on it for params and then a button they can click that will take the params and run the search with the params and display the result. You should be able to just redirect to the saved search w/ the params in the URL and that'll cut down some of the work.
b
I actually want to extend saved search. Use the same input from the users but show more related information. For context, we want to show opportunities related to a parent company and all the child companies related to that parent company.
c
well a custom suitelet would do this then. You'll have to have all of the filters and then a sublist that displays the results
b
I have used suitelet before to create a custom record. That is slightly different from this, as I don’t save anything here, just display the results. That is the part where I’m a little confused.
e
seems almost like something that can be done via a sublist though, no?
but, that said, you can modify the saved search then forward to the results in a new tab or the same
b
Can I display a sublist using the suitelet without actually saving any records?
c
Yeah you can. You could get all of your results for example and then display them in a custom sublist in the suitelet. Its just presenting data.
e
True. However, I believe you should be able to get similar data on the customer natively itself as well, no? just perform a search where the parent is this customer, that should prob get you all opportunities for children.
b
Thanks guys, I will give the suitelet way a try
It is not possible using the native saved search on the UI. Even NetSuite support gave us the custom page option.
Copy code
const form = serverWidget.createForm({
        title: "Related Opportunities for Parent and Sub Customers",
      });

      const reloppinfo = form.addFieldGroup({
        id: "reloppinfo",
        label: "Filters",
      });
      const customer = form.addField({
        id: "customerfield",
        type: serverWidget.FieldType.SELECT,
        label: "Supervisor",
        source: record.Type.CUSTOMER,
        container: "reloppinfo",
      });
      customer.defaultValue = data.customerfield;

      const sublist = form.addSublist({
        id: "oppsublist",
        type: serverWidget.SublistType.LIST,
        label: "Related Opportunities",
      });
      sublist.addField({
        id: "internalid",
        type: serverWidget.FieldType.TEXT,
        label: "Internal ID",
      });
      sublist.addField({
        id: "documentnumber",
        type: serverWidget.FieldType.TEXT,
        label: "Document Number",
      });

      form.selectNewLine({
        sublistId: "oppsublist",
      });
      prodRepRec.setCurrentSublistValue({ sublistId: "oppsublist", fieldId: "internalid", value: "123345" });
      prodRepRec.setCurrentSublistValue({ sublistId: "oppsublist", fieldId: "documentnumber", value: "123456" });
      prodRepRec.commitLine({ sublistId: sublistId });
I have this block of code on the
POST
section of the suitelet. It game me an error
form.selectNewLine is not a function
I don’t have a record here to run the method
selectNewLin
on How do I add lines to this sublist?
Also, please note the type of sublist is
LIST
. I don’t know if that makes any difference.
ok, I think I got it
Copy code
sublist.setSublistValue({ id: "internalid", line: 0, value: "123345" });
      sublist.setSublistValue({ id: "documentnumber", line: 0, value: "123456" });
I had to use
sublist.setSublistValue
instead
Thanks a lot again guys