Skip to main content
swapnar6405
Known Participant
March 1, 2023
Solved

Issue while getting document name by passing documentId

  • March 1, 2023
  • 5 replies
  • 2 views

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.

Best answer by nareshs945

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
March 1, 2023

please convert document id from list of variant to tointeger. 

Inspiring
March 1, 2023

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
March 1, 2023

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

Inspiring
March 1, 2023

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", "")
)