OSDK - Connecting/Using a function

Hi All,

I have downloaded the original To Do Application for OSDK, and I opened it using VS inside Foundry.

I then created a function in Foundry which I am trying to bring into my application. The function has the API Name: osdkTodoTaskSummarisation1

  1. I tried using Typescript Version 1.0 Method to get the function: (Which I got from Docs on Loading Functions)
client.ontology.queries
            .osdkTodoTaskSummarisation1({ osdkTodoProject: projectitem });

But when I do this, it says it cannot recognise the function and can’t find it, which is the issue.

  1. I then tried using Typescript Version 2.0 Method: (Which I got from importing my function into osdk, and the doc to use it)

const result = await client.ontology.queries.osdkTodoTaskSummarisation1({
    "osdkTodoProject": "{primaryKeyValue}"
});

But when I use this. it says some weird error about my client:

This expression is not callable.
  Type 'FoundryClient<PublicClientAuth>' has no call signatures.ts(2349)
  1. I am not sure what the issue is, I made sure to import the Function into the osdk. Do I need to refresh something for it to work? The only thing I am confused about is, in my developer console it says I have the function imported in. (Which is where I got the code from). However When I am in my Visual Studio Code, on the left hand side if I click 'Ontology" it only shows objects and actions. (Not sure if my function should be appearing here).

Anyone have any ideas which code I should be using, and then why it’s not working.

I have attached my code below:

import { MockProject} from "./mocks";
import client from "./client"

function aipfunction(projectitem: MockProject| null): string {
  
  if (!projectitem) {
    return "hey"
  }

  const FunctionV1 = client(osdkTodoTaskSummarisation1)({
    "osdkTodoProject": pk
  });

  const FunctionV2 =  client.ontology.queries
            .osdkTodoTaskSummarisation1({ osdkTodoProject: projectitem });


  //const finaloutput = FunctionV2.value.value

  return projectitem.id;
}

export default aipfunction;

Thanks for the question!
Based on your description it sounded like you were able to include it in the Dev console app but I am not sure if you generated a new version of the SDK? if you did, did you updated the package.json to the latest version of the SDK? if you did, you should sometime need to restart the ES server so VS code picks it up.
BLAB: - re-generate SDK, include latest version, refresh VS.

Hey, thanks for your response. It seems most likely you are correct as I didn’t recreate the sdk after uploading the new function.

Issue is, and I’m not sure if it’s related but I created new SDK, I tried to open my code in VS, but it’s blank. I attached a picture below. I don’t know how to fix this. I opened the Repo and all the code is there.

Have you tried to restart the container?

Yes I have restarted the workspace multiple times and it is still blank.

I can confirm that this is something we are currently investigating and hope we can resolve soon, Thanks for reporting.
As a workaround for now you can follow the instruction of running this locally in your IDE.

(might not be the case for this particular instance but when this happened to me I got it to work by logging out and using a chrome incognito window)