'How can I put HTML in sublist field?
I want to add a link to a sublist field. every line item will have different link
I tried with URL field but its just to put the link - I want to make the window small and put a img so i need html
objSublist.addField({
id: 'custpage_test',
type: serverWidget.FieldType.TEXT,
label: 'Test'
});
for (var i = 0; i < count; i++) {
//Set URL
newRec.setSublistValue({
sublistId: 'item',
fieldId: 'custpage_serials',
line: i,
value: '<html lang="en"><body><a href="https://www.example.com">Web site</a></body></html>'
});
}
Solution 1:[1]
You can still use a URL field and make it show a "Label" text instead of the full url:
objSublist.addField({
id: 'view',
type: serverWidget.FieldType.URL,
label: 'View'
}).linkText = 'View'; // you will see a "View" text instead of the URL.
But the downside here, is that because the "linkText" attribute is defined on the Field level, then you can not have a different "linkText" for each value on each line.
If you need to have a different text for each line, then you can include more sophisticated HTML code by using a field of type TextArea : something like this:
objSublist.addField({
id: 'appstepid',
type: serverWidget.FieldType.TEXTAREA,
label: 'ID'
});
objSublist.setSublistValue({
id: 'appstepid',
line: k,
value: '<a target="_blank" href="' + appStepUrl + '">' + appStep.id + '</a>'
});
And if the sublist is editable, then the TextArea field must be set to be displayed Inline:
objSublist.addField({
id: 'appstepid',
type: serverWidget.FieldType.TEXTAREA,
label: 'ID'
}).updateDisplayType({
displayType : serverWidget.FieldDisplayType.INLINE
});
Solution 2:[2]
Code for sublists is like so:
const serialsField = record.addField({
type: FieldType.SELECT,
id: "custpage_serials",
label: "Serials"
});
serialsField.addSelectOption({
value: "url1,
text: "URL 1",
isSelected: true
});
serialsField.addSelectOption({
value: "url2,
text: "URL 2"
});
etc...
Then you can add a client script to take sublist value, and use that to trigger window.open("my url") linking to a new page/tab
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | felipechang |