cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Servicenow serverlist into hopex server list macro example

murathoca
MEGA Partner
MEGA Partner

I want to add the graphql server list from ServiceNow to the hopex server list with a macro or api. Is there an example for this?

10 Replies

I have two questions. 1) How to transfer information from graph to Rest API with hopex. 2) How can we call and run a macro that I have thrown at you in hopex.

Hello,

 

You have to be clear on your goal :

 

  1. Server API : You do a macro JAVA inside HOPEX : you do not need GraphQL
  2. Server API : You do a macro in JAVA outside HOPEX that open HOPEX : you do not need GraphQL
  3. REST API : You do a development outside HOPEX you can make REST API call to access HOPEX with GraphQL.

 

The documentation you reference is for point 1.

 

I suggest your get in contact with your partner representative to get help on this topic of creating macro.

Our first goal is to execute this data from Hopex by writing the Graphql Json Data from Servicenow macro in Java. Of course, we take out the java file as a jar and save it in the java / lib folder. If you have a video to do this completely from the beginning, it would be nice or how you can help.

 

 

I did all the operation in the creation of java component in hopex v3 documents on doc.mega.com in order

https://doc.mega.com/hopex-v3-en/#page/MTS2%2FAPI%2FAll_about_starting_with_APIs.Create_a_Java_compo...

 

I ran this command in the document to run the java macro

 

 

GetRoot.CurrentEnvironment.GetMacro("MegaPlugin").writeInFile "c:\temp\testfile", "Some text..."

 

but when i run this command i get the error in the attached picture.

 

my first aim is to run a macro written in java in hopex.

 

 

 

 

Hello, thank you for answering, but your answer is not working. I will write an answer that tells you what I want to do.

I can't give you example of code just like that. You need to have a pragmatic approach and follow the step :

  1. What do you want to achieve (see screenshot)
  2. what high level mapping do you have : is it one to one ? (see screenshot=)
    1. MetaClass in HOPEX : are you in ITPM or Architecture ?
    2. Table in Service Now
  3. What is the visual of all the relationship (see class diagrams example)
  4. What is the detailed mapping (see excel file example attached)
  5. Which business rules of transformation ?
  6. Which GraphQL query you should write to 
    1. read information in HOPEX
    2. write information in HOPEX
steps.png

 

steps2.png

 

Service Now - 1 _ Overview.png

 

Service Now - Server.png

 

 

Example of GraphQL queries :

 

Reading Server deployed in ITPM

query {
  serverDeployed {
    id
    name
    comment
    beginLifedate
    endlifedate
    operatingExpenses
  }
}

 

Creating or updating server deployed in ITPM :

mutation createupdate {
  createUpdateServerDeployed(id:"sys_id service now" idType:EXTERNAL serverDeployed:{
    name:"new server from service now"
    comment:"comment comming from service now"
  }) {
    id
    externalId
    name
  }
}

 

 

You have a sample code to convert JSON from Service Now to a JSON compatible with the GraphQL REST API.

 

we want to make our own script but need a simple example a video or a code how to do this process

 

please Mr. oguimard

I seem to recognize a JSON coming from Service Now ?

 

You need to convert this JSON from Service Now to a JSON compatible with GraphQL REST API.

 

This is exactly what is the link I gave you do. It is done using Talend as a mean to do the conversion. Yet, you can develop your own script.

We want to throw the graphql query result below to the IT Server List in hopex using the macro. To do this, do you have a sample macro code or how can we send this API with code?

 

 

 

{

"result":[

{

"end_date":"10.12.2019 15:30:00","phase":"Executing","number":"PRJ0010010","short_description":"KOPİ (Karşılığı Olmayan Piyasa İşlemleri Projesi)","primary_portfolio":{"display_value":"Piyasa","link":"h target=_blankttp://prpexist.epias.com.tr/api/now/table/pm_portfolio/2bd6f3014c4be3007ee32d4a8f033c..."},"project_manager":{"display_value":"Selcen Toraman","link":"h target=_blankttp://prpexist.epias.com.tr/api/now/table/sys_user/1dff5ab2353b03007ee3d91ba25d953d"},"percent_complete":"63,75","start_date":"17.10.2018 08:00:00"},{"end_date":"01.01.2021 08:30:00","phase":"Executing","number":"PRJ0010011","short_description":"İTEP ( İleri Tarihli Fiziksel Teslimatlı Elektrik Piyasası Projesi )","primary_portfolio":{"display_value":"Piyasa","link":"htt target=_blankp://prpexist.epias.com.tr/api/now/table/pm_portfolio/2bd6f3014c4be3007ee32d4a8f033c..."},"project_manager":{"display_value":"Selcen Toraman","link":"htt target=_blankp://prpexist.epias.com.tr/api/now/table/sys_user/1dff5ab2353b03007ee3d91ba25d953d"},"percent_complete":"17,36","start_date":"11.03.2019 08:30:00"},{"end_date":"25.03.2019 17:00:00","phase":"Delivering","number":"PRJ0010012","short_description":"Oracle 12c upgrade Projesi","primary_portfolio":{"display_value":"BT","link":"htt target=_blankp://prpexist.epias.com.tr/api/now/table/pm_portfolio/9fd47b8d4c0be3007ee32d4a8f033c..."},"project_manager":{"display_value":"Necat Demirağ","link":"htt target=_blankp://prpexist.epias.com.tr/api/now/table/sys_user/24777525143813007ee334f79f07a1b6"},"percent_complete":"100","start_date":"26.11.2018 08:30:00"},{"end_date":"22.03.2019 08:00:00","phase":"Delivering","number":"PRJ0010015","short_description":"Mobil Uygulama Doğal Gaz Modülü","primary_portfolio":{"display_value":"Piyasa","link":"htt target=_blankp://prpexist.epias.com.tr/api/now/table/pm_portfolio/2bd6f3014c4be3007ee32d4a8f033c..."},"project_manager":{"display_value":"Selcen Toraman","link":"htt target=_blankp://prpexist.epias.com.tr/api/now/table/sys_user/1dff5ab2353b03007ee3d91ba25d953d"},"percent_complete":"100","start_date":"27.11.2018 08:00:00"},{"end_date":"03.11.2020 08:00:00","phase":"Executing","number":"PRJ0010019","short_description":"EPYS ( Enerji Piyasası Yönetim Sistemi Projesi )","primary_portfolio":{"display_value":"Piyasa","link":"htt target=_blankp://prpexist.epias.com.tr/api/now/table/pm_portfolio/2bd6f3014c4be3007ee32d4a8f033c..."},"project_manager":{"display_value":"Necat Demirağ","link":"htt target=_blankp://prpexist.epias.com.tr/api/now/table/sys_user/24777525143813007ee334f79f07a1b6"},"percent_complete":"17,78","start_date":"24.07.2018 08:00:00"},{"end_date":"20.05.2019 17:00:00","phase":"Planning","number":"PRJ0010021","short_description":"EPİAŞ Kurumsal Mimari Projesi","primary_portfolio":"","project_manager":{"display_value":"Umut Özfidan","link":"http target=_blank://prpexist.epias.com.tr/api/now/table/sys_user/77aaf917555c73802e63a00265e6f1bd"},"percent_complete":"0","start_date":"20.05.2019 08:00:00"},{"end_date":"10.02.2020 17:00:00","phase":"Delivering","number":"PRJ0010033","short_description":"TEST KS","primary_portfolio":"","project_manager":{"display_value":"Erdem Akman","link":"http target=_blank://prpexist.epias.com.tr/api/now/table/sys_user/e8ff1ab2353b03007ee3d91ba25d958f"},"percent_complete":"100","start_date":"10.02.2020 08:00:00"}]}

oguimard
Retired

Hello,

 

i'm not sure I understand your need.

 

I recommend you to read this information https://community.mega.com/t5/HOPEX-Store/Service-Now-integration/td-p/21383

 

This is an add-on about integration with Service Now leverging the REST API.

 

Let me know if this is what you are looking for.