Skip to main content

Notifications

Announcements

No record found.

Power Platform Community / Forums / General / Inconsistent behaviour...
General
Unanswered

Inconsistent behaviour in FX Formula - Trying to get Key values from object in Copliot Studio

Posted on by

Hi,

 

I am using Copilot Studio and I am trying to get the value of Keys from an object. This works when using the Servicenow Connector 'Get Knowledge Articles', however, it does not work when using the Servicenow Connecter 'Get Records' even though the returned object is the same, just contains different keys/values. Can someone please explain how I am able to retrieve the values form the kb connector but not the get records connector and show me where I am going wrong? 

 

I am getting the errors: Name isn't valid. 'active' isnt recognized

Even though the active key is in the returned object (can see from code below)

 

Any help would be appreciated!

 

Return of Servicenow Connector 'Get Knowledge Articles':

{
 "articles": [
 {
 "id": "kb_knowledge:ac85a0c4c3437158d3649c0c050131ad",
 "link": "?sys_kb_id=ac85a0c4c3437158d3649c0c050131ad&id=kb_article_view&sysparm_rank=1&sysparm_tsqueryId=c0cb94a0c3250a501074fdbb0501315b",
 "number": "KB0012536",
 "rank": 1,
 "score": 239.6025,
 "snippet": " to the Spark library of knowledge articles. Here you can find lots of useful information. <strong>Report</strong> a <strong>Fault</strong> Tile The '<strong>Report</strong> a <strong>Fault</strong>' tile is a link to the catalog of Spark forms used to raise Incidents. Browsing the 'Approvals' menu link which also has a badge to indicate <strong>how</strong> many outstanding approvals you have. From",
 "title": "Tech Self Service - How to guide"
 }
}

Formula to get key values from above code and to pass to Generative answer node:

ForAll(
 Topic.GetKnowledgeArticles.articles, {
 Content: Concatenate(title, " - ", snippet),
 ContentLocation: Concatenate("https://skydev3.service-now.com/techss?id=tk_article&sys_id=", Last(Split(id, ":")).Value)
 }
 )

 

Return of Servicenow Connector 'Get Record' (I have removed some fields so it isnt as long):

{
 "result": [
 {
 "active": "true",
 "activity_due": "UNKNOWN",
 "additional_assignee_list": "",
 "agile_story": "",
 "approval": "Not Yet Requested",
 "approval_history": "",
 "approval_set": "",
 "assigned_to": "",
}
]
}

 

Formula to get key values from above code and to pass to Generative answer node:

ForAll(
 Topic.GetRecords.result,
 {
 Content: Concatenate(active, " - ", approval),
 ContentLocation: activity_due
 }
 )

 

 

  • MattJimison Profile Picture
    MattJimison on at
    Re: Inconsistent behaviour in FX Formula - Trying to get Key values from object in Copliot Studio

    Hi, @BenMadine .

     

    The reason you see different behavior between the 2 different ServiceNow actions is because the "List Records" action doesn't come back with a typed result that is aware of the columns retrieved in the table, because it can bring back content from any table in ServiceNow. The reason the Knowledge Articles action works is because it knows the data its bringing back and the connector provides that schema within its return value.

     

    If you look at the schema of the List Records' GetRecords record you'll see it's:

     

    kind: Record
    properties:
     result:
     order: 0
     type:
     kind: Table
     properties:
     Value: Any

     

     

    That's the crux of the issue for this particular connector, where its saying the result table can contain any number of properties (columns). This is why you see errors trying to refer to the active, activity_due, etc. columns, because it has no idea what those are.

     

    Cheers,

    Matt

     


    Find this post helpful? Please mark it as the solution and/or provide kudos so that it will help others in the future.

    Cheers,
    Matt

  • BenMadine Profile Picture
    BenMadine on at
    Re: Inconsistent behaviour in FX Formula - Trying to get Key values from object in Copliot Studio

    Hi,

     

    I am trying to pass in the results of a Servicenow Connector to a Generative Answers Node. I have the Connector which is returning results and then I am trying to format the results in a format that the Generative Answers Node can read. So 

    ForAll(
     Topic.GetRecords.result,
     {
     Content: Concatenate("active", " - ", "approval"),
     ContentLocation: "activity_due"
     }
     )

    writing the code like that works because Im passing in 'active' as a string. However 'active' is a key in the object returned from the Servicenow Connector results so it should recognise it as a key, no? It recognises the keys from the Servicenow Knowledge Base Connector, so I am unsure why it doesnt with the Get Records Connector?

     

    I have attached images of the flow, the formula with issues and the formula with the working knowledge base connector keys.

     

    Thanks,

    Ben

  • v-jefferni Profile Picture
    v-jefferni on at
    Re: Inconsistent behaviour in FX Formula - Trying to get Key values from object in Copliot Studio

    Hi @BenMadine ,

     

    Could you please share more details about your scenario? Which node are you using in this topic?

     

    If I use a message node and add an adaptive card, no error emerged. Could you share some screenshots?

     

    Best regards,

Helpful resources

Quick Links

Exciting News for Copilot Studio Communi…

Get ready to experience a whole new level of engagement with the Copilot Studio…

Celebrating the May Super User of the…

LaurensM is an exceptional contributor to the Power Platform Community…

Check out the Copilot Studio Cookbook…

We are excited to announce our new Copilot Cookbook Gallery in the Community…