Import and Transform Maps - Issues with Parent.

altacc
Giga Expert

Hi.

I have spend many hours and I'm tearing my hair out on this - I've tried so many different things and no joy, even though it seems quite simple (I'd have done it in 2 minutes in SQL Server!)

The issue -

I'm trying to import Location data, including setting the parent. Some Locations have no sub locations and some have sub locations of the same name as other sub locations. E.g.

Building 1

Building 2

--Floor 1

--Floor 2

Building 3

--Floor 1

--Extension

Due to the nature of the tree picker in Service Now only showing the child element when chosen, and which would be confusing for "Floor 1" in the above example, I have reorganised the above data as follows -

Building 1

Building 2

--Building 2 - Floor 1

--Building 2 - Floor 2

Building 3

--Building 3 - Floor 1

--Building 3 - Extension

As well as being clearer when chosen in Service Now it also provides a unique field which I thought would help make things work.

However, when I import and transform I get the following -

Building 1

Building 1 (parent Building 1)

Building 2

Building 2 (parent Building 2)

Building 2 - Floor 1 (parent Building 2)

Building 2 - Floor 2 (parent Building 2)

Building 3

Building 3 (parent Building 3)

Building 3 - Floor 1 (parent Building 3)

Building 3 - Extension (parent Building 3)

So basically I get a "bad" record for every parent, where it creates a row with a parent to itself. I have tried adding in code to get around this. I added this to the onBefore -

  if (source.u_fulllocation == target.name)

      ignore=true;

The result is that no updates are done to parent at all. And I also tried a different way, adding the following to the field map script for the parent field -

  if (source.u_fulllocation == source.u_location) {

      return null; }

  else {

      return source.u_location;

  }

Again, no updates are done to parent in this case. A lot of this is trial and error - I'm fairly new to Service Now and javascript but this seems to me something that should be very simple... but isn't turning out that way.

If anyone can help I would much appreciate it.

5 REPLIES 5

I should add that the above results were doing the transform in a 2 step process whereas my initial post described what happened in a one step process.



Here is what happens in a one step process, first with "ignore" and then with the default "create" -



sn3.PNG



SN4.PNG



As you can see - the three results all give me elements of what I want, but none of them is right in all instances! It's so annoying!