- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2016 07:52 AM
Can i use current.name.endsWith() in a BR? It doesnt seem to only be running on those conditions but is meeting all conditions. As if the condition does not apply
function onBefore(current, previous) {
//This function will be automatically called when this rule is processed.
if (current.name.endsWith('foo') || current.name.endsWith('bar')){
var gr= new GlideRecord('table') .................
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2016 09:04 AM
i ended up moving the condition in the script up to the actual condition on the BR, and that worked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2016 07:55 AM
use this
if(current.name.slice(-3)=='foo' || current.name.slice(-3)=='bar')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2016 08:23 AM
Does this still apply if I have a name thats longer than 3 char?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2016 09:23 AM
yea, any length
current.name.slice(-3) //this will extract last 3 characters of the string

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2016 08:14 AM
Hi,
endsWith will work in global scope but not in scoped applications.