I'm trying to set a link to preset a field on my form. For example if they click "Oracle ticket", it opens the form with Oracle already populated. (This field is a choice, drop down list)
I found a post saying to use This code:
fd.rendered(function() {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
// Replace SingleLineText0 with teh internal name of the field
// 'id' is the name of the parametr
fd.field('Case_x0020_Category').value = urlParams.get('id');
});
And the URL I add &id=1 and nothing happens. I have 2 form sets and I have set the JS on both of them and still can't get it to trip.
Here is the URL I'm using with the domain X'ed out.
First, you need to remove #/ from the URL:
4e5e5c/NewForm.aspx #/ ?spform-List=9a332e69-56eb-461a-86c1-
And if you are using forms for SharePoint, you need to run your code under spRendered event, like this:
fd.spRendered(function () {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
// Replace SingleLineText0 with the internal name of the field
// 'id' is the name of the parametr
fd.field('Case_x0020_Category').value = urlParams.get('id');
});