I have created a custom INLINE HTML field that I w...
# suitescript
w
I have created a custom INLINE HTML field that I would like to be able to update on fieldChanged client script. The script I have works fine as I can update other fields on the record. I can also use the browser console and type nlapiSetFieldValue('custbody_inlinehtml','New HTML here') and it will update. My end goal is to display a custom record in an iframe based on what the user picks from a list.
r
I'm not sure I completely understand what you're after, but you could probably save a lot of time and effort by just using SuiteBuilder to create a parent-child relationship. Child records can easily be configured to show on parent records.
You can use Custom Views to pick from a list based on Criteria.
w
I'll have to take a look at SuiteBuilder. So we maintain generators for our customers. On or Sales Order we have a MultiSelect that allows you to pick the generator (Custom Record) that we will be billing the parts and labour too. We store a lot of info on these generator custom records and I would like for it to be readily available on the Sales order.
r
So I'm guessing you already have a link that you can click on the sales order, right? So you just want it to be a pop up instead of another window/tab?
w
Yes... but I'd prefer it to just display instead of pop up.
message has been deleted
r
Right on, I'm with you. What's the problem?
w
My script doesn't update the Inline HTML field to display.
So I wasn't sure if Nestuite will allow it to even work.
r
Not sure, I've definitely seen iframes used for this type of thing in the past, but mainly suitelets, portlet scripts, etc. Show code?
w
Copy code
function fieldChanged(context) {
            var currentRecord = context.currentRecord;

            var fieldName = context.fieldId;


            if (fieldName === 'custbody_sansom_customer_equipment') {
                var accountURL = url.resolveDomain({
                    hostType: url.HostType.APPLICATION,
                });
                log.debug({
                    title: 'accountURL',
                    details: accountURL
                })
               var equipmentSelected = currentRecord.getValue({
                    fieldId: 'custbody_sansom_customer_equipment'
                });
                log.debug({
                    title: 'equipmentSelected',
                    details: equipmentSelected
                })

                var equipmentRecordURL = url.resolveRecord({
                    recordType: 'customrecord_sansom_equipment',
                    recordId: equipmentSelected[0],
                    isEditMode: false
                });
                log.debug({
                    title: 'equipmentRecordURL',
                    details: equipmentRecordURL
                })
                var noMenuBar =  '&l=T'  //this removes the menu bar. Like the popout records

                var iframe =  "<iframe src=\"https://" + accountURL+equipmentRecordURL+noMenuBar + "\" width=\"1200\" height=\"1200\" title=\"Equip Card\"></iframe>";
                log.debug({
                    title: 'iframe',
                    details: iframe
                });

                //var equipmentRecordDisplay = '';

                currentRecord.setValue({
                    fieldId: 'custbody_sansom_correction_so',
                    value: iframe
                })

                // log.debug({
                //     title: 'equipmentRecordDisplay',
                //     details: equipmentRecordDisplay
                // })



            }; // END IF


        }
Sorry.. the setValue is actually a different field I was using to test
Copy code
custbody_sansom_correction_so
this is a Text Area and will update from the iframe variable.
The acutal field is custbody_so_equip_rec_display, which is a custom Inline HTML.
message has been deleted
@reptar I just did some Google-Fu and found this reply stating it cannot be done but there is a work around: https://netsuiteprofessionals.com/blog/question/how-to-set-inline-html-field-value-in-netsuite-via-script/
Which doesn't work because I would need to refresh the INLINE HTML field after the other field is set.
@reptar I have somethings that is working:
Copy code
window.nlapiSetFieldValue('custbody_so_equip_rec_display', iframe);
Found it here: https://stackoverflow.com/questions/45933536/setting-inline-html-field-from-client-script-in-suitescript-2-0
r
window.nlapi.... that's working?
I was gonna say, if you just want to create a suitelet, you could pass an id to the SL as a parameter and just build the HTML instead of using an iframe. Then you can hit the SL on fieldChanged and set the value of the HTML field.
These type of suitelets are sometimes referred to as "back end suitelets".
w
So the window.nlapi works great in EDIT but not in view.
I like the suitelet idea. I'll give that a try. Thank you very much for your time.
r
actually, that's not a bad use case for a restlet either...
w
ah yes true.