1

I am trying to use the Logic Apps ServiceNow connector.

I have got most of the fields from the request, the last item which i need are the variables text inputs in ServiceNow. I have identified that i can get the information from sc_item_option_mtom table and sc_item_option respectively.

The output of sc_item_option_mtom looks like below -

     "result": [
                    {
                        "sys_id": "00d1ce4adb75c4144664a27314961454",
                        "sys_updated_by": "Bot.One",
                        "sys_created_on": "04/01/2020 12:23:21",
                        "sys_mod_count": "0",
                        "request_item": {
                            "display_value": "RITM0032344",
                            "link": "https://dev.service-now.com/api/now/v2/table/sc_req_item/ggd1ce4adb75c4144664a2731496195f"
                        },
                        "sc_item_option": {
                            "display_value": "ggd1ce4adb75c4144664a2731496195e",
                            "link": "https://dev.service-now.com/api/now/v2/table/sc_item_option/ggd1ce4adb75c4144664a2731496195e"
                        },
                        "sys_updated_on": "04/01/2020 12:23:21",
                        "sys_tags": "",
                        "sys_created_by": "Bot.One"
                    }
                  ]

I need to get sc_item_option.display_value to be used as a input into the sc_item_option table. When i do this in Logic apps, it create a for each loop(which is correct), but the option i get is a Dependent Item

Logic apps setup

When i run the logic app the Dependent Item looks like -

"sys_id={\"display_value\":\"ggd1ce4adb75c4144664a2731496195e\",\"link\":\"https://dev.service-now.com/api/now/v2/table/sc_item_option/ggd1ce4adb75c4144664a2731496195e"}"},

I've tried editing the code to just get the display_value. Things i have tried are -

  • sc_item_option.display_value.[0]
  • sc_item_option.display_value[0]
  • sc_item_option.[0]
  • sc_item_option[0]

Nothing seems to work and not give me the value which is in display_value.

Can someone help me and tell me what i am doing wrong ?

Full List Records file -

  "result": [
            {
                "sys_id": "00d1ce4adb75c4144664a27314961454",
                "sys_updated_by": "Bot.One",
                "sys_created_on": "04/01/2020 12:23:21",
                "sys_mod_count": "0",
                "request_item": {
                    "display_value": "RITM0032344",
                    "link": "https://yarratramsau.service-now.com/api/now/v2/table/sc_req_item/ggd1ce4adb75c4144664a2731496195f"
                },
                "sc_item_option": {
                    "display_value": "ccd1ce4adb75c4144664a2731496195e",
                    "link": "https://yarratramsau.service-now.com/api/now/v2/table/sc_item_option/ggd1ce4adb75c4144664a2731496195e"
                },
                "sys_updated_on": "04/01/2020 12:23:21",
                "sys_tags": "",
                "sys_created_by": "Bot.One"
            },
            {
                "sys_id": "0cd1ce4adb75c4144664a27314961960",
                "sys_updated_by": "Bot.One",
                "sys_created_on": "04/01/2020 12:23:21",
                "sys_mod_count": "0",
                "request_item": {
                    "display_value": "RITM0032344",
                    "link": "https://yarratramsau.service-now.com/api/now/v2/table/sc_req_item/ggd1ce4adb75c4144664a2731496195f"
                },
                "sc_item_option": {
                    "display_value": "4fd1ce4adb75c4144664a2731496195e",
                    "link": "https://yarratramsau.service-now.com/api/now/v2/table/sc_item_option/4fd1ce4adb75c4144664a2731496195e"
                },
                "sys_updated_on": "04/01/2020 12:23:21",
                "sys_tags": "",
                "sys_created_by": "Bot.One"
            },
            {
                "sys_id": "c0d1ce4adb75c4144664a27314961960",
                "sys_updated_by": "Bot.One",
                "sys_created_on": "04/01/2020 12:23:21",
                "sys_mod_count": "0",
                "request_item": {
                    "display_value": "RITM0032344",
                    "link": "https://yarratramsau.service-now.com/api/now/v2/table/sc_req_item/ggd1ce4adb75c4144664a2731496195f"
                },
                "sc_item_option": {
                    "display_value": "40a1ce4adb75c4144664a2731496195f",
                    "link": "https://yarratramsau.service-now.com/api/now/v2/table/sc_item_option/40a1ce4adb75c4144664a2731496195f"
                },
                "sys_updated_on": "04/01/2020 12:23:21",
                "sys_tags": "",
                "sys_created_by": "Bot.One"
            }
        ]

Warlord
  • 37
  • 1
  • 11

1 Answers1

1

You can try to use this expression below to fill in the "Query" box of "List Records" action:

body('Item_Options(sc_item_option_mtom)')[0].sc_item_option.display_value

By the way, it seems there is just one item in the result of "sc_item_option_mtom", so you do not need to use the "For each" loop(I know it would create the "For each" automatically), but you just need to create the "List Records" action and input the expression above to the "Query" box of the action directly(without "For each" loop).

Update:

For the update of your requirements, you can refer to the solution below:

Input the expression below to the "Query" box of "List Records" action:

items('For_each').sc_item_option.display_value

enter image description here

So in the "Query" box of "List Records" action, it should be like:

enter image description here

Hury Shen
  • 14,948
  • 1
  • 9
  • 18
  • I tired doing sys_id=body('Item_Options(sc_item_option_mtom)')[0].sc_item_option.display_value - it didn't really work. – Warlord Jan 09 '20 at 02:28
  • Hi @Warlord, could you please provide a screenshot of the "List Records" in your logic app ? – Hury Shen Jan 09 '20 at 02:33
  • I have added the full output of the result and to answer your question earlier, the sc_item_option does repeats for a single item, because there couple be multiple fields. Therefore there is a foreach loop. Thanks for your help ! – Warlord Jan 09 '20 at 02:41
  • @Warlord, sorry, I mean want a screenshot of the "List Records" action. But according to the json data of "List Records" you provided, I saw there is more than one items in the json data. So please wait a moment, I will modify my answer later to match your requirements. And still ask for a screenshot of the "List Record" action in your logic app(not the json data) – Hury Shen Jan 09 '20 at 02:45
  • Hi @Warlord, I have updated my answer, please refer to the solution I updated. If still have any problems, please free to let me know. – Hury Shen Jan 09 '20 at 03:07
  • Thanks for the update @Hury Shen - i was able to use the code snippet and make it work. – Warlord Jan 10 '20 at 02:30