document.getElementById : how to set value when there is no ID?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2020 09:08 PM
I need to set some values from the console in this process I have used something similar on the same form and works great:
document.getElementById("s2id_sp_formfield_subcategory").value = "Car Hire";
The above was a text field.
I have a reference variable and I want to add value similar to above. The problem is I cannot find the 'ID'. What options do I have to populate in that text box from console as above?
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2020 09:16 PM
document.getElementById() does not work on portal, why are you setting the value from console ? may i know the exact requirement ?
Note: DOM does not work when you are using client script,
did you try with getElementsByClassName()
https://www.w3schools.com/jsref/met_document_getelementsbyclassname.asp

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2020 11:10 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2020 01:41 AM
Hi All,
Thank you for the response.
This is not a Development effort. I'm not writing any scripts here.
I'm trying to help our testers on a one-time effort but needs to be tested with various combinations.
Imagine a catalog variable on a portal is referencing the 'subcategory' table (also has a field called subcategory). As a part of a larger exercise, our testers are expected to hand-pick few such records and test various scenarios.
It would be useful to either write a small javascript from console or use the 'Auto fill' plugin (which also uses javascript) to try those scenarios.
I have used in the past even on a portal (including the current catalog item but for text fields) and works like a charm. Unfortunately I cannot see an 'ID' for the above element.
I tried getElementsByClassName etc., too but without success.
Hence if you know an alternative way to populate values in the field where 'ID' is not visible, that would be a big favor for me.
Thanks for reading!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2020 01:52 AM
why don't you try with ATF , just build your test cases and let them test it.
Doc link for further details.