
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2019 10:58 AM
Hi,
I need to use startsWith() function on a client script, but I got this error.
onChange script error: TypeError: location.startsWith is not a function function () { [native code] }
please help?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2019 09:17 AM
I fixed it, I have to add .name to the location.
Than you all.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var location = g_form.getReference('u_fac_building');
//g_form.addInfoMessage(location.name);
if(location.name.substring(0,4) == "0152"){
g_form.setValue('assigned_to','442d90fa4f4f8b003aeb58211310c784');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2019 03:46 PM
Since you only want to know about the start of the string "indexof" won't work, but substring should.
How about this:-
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var location = g_form.getReference('u_fac_building');'
if(location.substring(0,4) == "0152"){
g_form.setValue('assigned_to','');
}
}
Thanks...Gary

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2019 09:12 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2019 09:17 AM
I fixed it, I have to add .name to the location.
Than you all.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var location = g_form.getReference('u_fac_building');
//g_form.addInfoMessage(location.name);
if(location.name.substring(0,4) == "0152"){
g_form.setValue('assigned_to','442d90fa4f4f8b003aeb58211310c784');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2022 12:52 PM
What is "name" define here , i have same requirement where the field is refrence type and it has numeric number . i want if the field starts with number 12 then it will populate error message