Skip to main content
swapnar6405
Known Participant
Mar 1, 2023 10:09 PM UTC
Solved

Issue while getting document name by passing documentId

Hi,

I am trying to get the document name by passing the documentId. If I am fetching the documentid into a local variable and pass, then I am getting an error. Where as when I pass the documentId number manually, I am getting required output.

Not sure what is wrong. Do I need to do any kind of conversion before assign to a local variable.

a!localVariables(

local!templateDetails: rule!LC_getTemp(Key: 4),
local!documentId: index(local!templateDetails, "documentid",null()),
local!documentId
/*document(local!documentId,"name")*/
)

When I try to execute below code, I am getting below output.

a!localVariables(
local!templateDetails: rule!LC_getTemp(Key: 4),
local!documentId: index(local!templateDetails, "documentid",null()),
document(local!documentId,"name")
)

Whereas when I try to execute the above code, I am getting the below error. Can someone advice here.

Inspiring
Mar 1, 2023 10:25 PM UTC

Use the following logic.

a!localVariables(

  local!templateDetails: rule!LC_getTemp(Key: 4),
  local!documentId: cast(1,index(local!templateDetails, "documentid",null())),
  document(local!documentId, "name", "")
)

5 replies

pragnaj0001
Inspiring
Mar 1, 2023 10:17 PM UTC

please convert document id from list of variant to tointeger. 

Inspiring
Mar 1, 2023 10:19 PM UTC

it is casting error. cast your documentId to integer.

a!localVariables(

  local!templateDetails: rule!LC_getTemp(Key: 4),
  local!documentId: tointeger(nindex(local!templateDetails, "documentid",null())),
  document(local!documentId, "name", "")
)

swapnar6405
Known Participant
Mar 1, 2023 10:22 PM UTC

Even if I convert to integer, I am getting an error

Inspiring
Mar 1, 2023 10:25 PM UTC

Use the following logic.

a!localVariables(

  local!templateDetails: rule!LC_getTemp(Key: 4),
  local!documentId: cast(1,index(local!templateDetails, "documentid",null())),
  document(local!documentId, "name", "")
)