I'm battling some existing processes and trying to...
# suitescript
r
I'm battling some existing processes and trying to implement manual entry POs for the first time. users are already using Requisitions and then Buyers use Order Requisitions, so I can't change the new form I created to the preferred form as it would impact that native process. The best solution I've come up with so far is to set the custom form on
pageInit
, but it's a terrible solution. The page fully loads and then jerks the user into reloading the page. Has anyone come up with a better solution for forcing users onto a new form without setting it as preferred? I've added an alert letting the user know they can bookmark the page they get redirected to, but I don't like this UX. at all.
j
I'm gonna see if setting the
customform
on beforeLoad works. I'm assuming you've already tried this but I need to see lol
okay it doesn't ._.
e
^ In
beforeLoad
, I believe you can use redirect.toRecord and set
cf
to the desired custom form in the
parameters
option.
thankyou 1
netsuite halo 1
j
iiiiiiiinteresting
Copy code
beforeLoad: function(scriptContext) {
      if (scriptContext.newRecord.getValue('customform') != 115) {
        redirect.redirect({
          url: '/app/accounting/transactions/vendbill.nl?whence=',
          parameters: {
              'cf': MY_FORM
          }
        });
      }
    },
here's what I did
have to put in that conditional or else you get "too many redirects"
oh. and I did it with VBs because that's what I was working on like 2 minutes ago
e
I might replace that
redirect.redirect()
with:
Copy code
redirect.toRecord({
  ...context.newRecord,
  parameters: {
    cf: MY_FORM
  }
})
or if you don't like spread syntax, then:
Copy code
redirect.toRecord({
  type: context.newRecord.type,
  id: context.newRecord.id,
  parameters: {
    cf: MY_FORM
  }
})
e
Did the
redirect.toRecord()
approach work in a
beforeLoad
? That should avoid the page reload issue since it happens server-side.
r
It did. works great
had to set the employee on the client side
that param didn't take
e
I know there's a consistent way to set fields via URL params, but I always forget what it is. I'm sure someone here remembers
m
&record.employee=123
1
thankyou 1