How can I determine the selected `customform` of a...
# suitescript
j
How can I determine the selected
customform
of a Support Case record in view mode in a User Event script? Use case: I need to conditionally hide/show some fields on the record in both edit/view mode but only on this particular custom form.
c
Have you tried
context.newRecord.getValue({ fieldId: "customform" })
?
j
it’s null in view
c
Can you deploy a client script directly to the custom form in question that manages field visibility?
j
That would only work in edit mode tho
client scripts deployed directly to a particular custom form only run in edit mode
c
Ah gotcha - I'm not familiar with that usage
j
this is frustrating. Obviously the record KNOWS what form it’s using
but SS can’t get at it
c
@michoel might know - his Field Explorer Chrome extension shows the customform in View mode, possibly through some browser JS fun.
m
I think you can get it with
search.lookupFields()
(at least you can for transactions), though obviously that's less than ideal from a performance standpoint.
j
I had the same thought but no joy, not exposed to search like it is on transactions
m
Well that's a darn shame. In that case I have no idea what the best option would be. Absolute worst-case, could you add a new field that copies over the ID of the custom form in beforeSubmit or something?
⬆️ 1
c
@MTNathan Since multiple users might access the record using different forms based on Role preferences and restrictions, I'm not sure that would scale
m
True, I guess it depends on if you have restricted forms for cases. Though in that case maybe you could use the user's current role as a proxy for which form is being used?
c
Unfortunately, if a Role has access to more than one form, that won't be reliable.
j
unfortunately all roles use many forms
I can’t copy the value over, we have hundreds of thousands of existing Support Case records.
c
Could you create a field that does not store a value, do not show it on the form, customize the label on the custom form, then load that Field's label in beforeLoad? @jen
@jen Ok yeah, I've tested this. I created a field that I do not show on the form, and on one custom form, I set the label to a unique string. I can then get the label string from
Record.getField().label
. This works as a proxy for the custom form and is accessible in View mode.
👍 1
j
so I’ve done something similar. I do already have a field that only shows on this form (stored). Since I already have a client script that runs on all the forms, in that script, I’m checking if my “this form only” field is visible. If so, I’m on my desired form and I think I can probably do what I need to do with that info, even though it’s in Client script and not UE.
1
c
Nice! If you do end up need to move into UE, the approach I outlined above works in
beforeLoad
👍 1