Get substring after backslash in a string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2013 09:37 AM
hi
I have a string that contains a backslash.I want the substring after backslash. How can i get it?I tried substring function but its not working.PLease help me out.
example if the string is "first\last" I want to store 'last' in a variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2013 06:54 PM
Hi,
I have only one backslash in my string and this string is coming from SCCM.Yes, its looking simple to split this string but its not.for the double backslash \\ its working fine,but i need the solution for the single backslash '\'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2013 07:15 PM
its not a double slash. its a single slash, you are escaping it using another slash.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2013 07:33 AM
Hi, I ran into the same thing. I'm pulling the last logon from SCCM into Service-Now. On the "SMS / SCCM Computer System" data source, the transform map is "SMS Computer_System_DATA" in the SCCM version 2 plugin out of the box. I have added a field called u_lastlogon to capture the last logged in user from SCCM.
I have an onBefore transform script that sets the u_lastlogon field with the following:
var uname = source.u_username0.toString();
var names = uname.split("\\");
if (names.length == 2) {
source.u_username0 = names[1];
}
You escape in the javascript, you don't have to alter what SCCM stores. For instance, SCCM would have domain\user in this column, I am splitting on \ but you have to escape it in your javascript with \\.
You could probably also set it via a script in your transform mapping as well. I'm not sure why I used an onBefore transform script on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2015 07:31 PM
Hi Gary,
I am trying to implement Last Login user and Date/time feature in ServiceNow. Could you please confirm which tables captures this information or if you could provide me the query you used.
I am using SCCM 2012.
Regards,
N Dubey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2016 12:15 AM
I had some problem using the substr(n, m) function. Use the substring(n, m) function and it's working fine.