User bio
404 bio not found
Member since Jan 11, 2018
Replies:

Thanks for responding.

while i was using your code, i am getting this error in response, which says "read" method is unknown

{
    "Error": "ERROR #5002: Cache error: <METHOD DOES NOT EXIST>zCheckMissingRoleName+3^Controllers.Roles.2 *Read,%Library.ListOfObjects"
}

If just take out that "read method", then i am getting this error

{
    "Error": "ERROR #5002: Cache error: <INVALID OREF>zCheckMissingRoleName+16^Controllers.Roles.3"
}

I will give my requirement as it is.

I am getting an json array of Roles object, in which only "name" property is sent. I have to see if these names are present in DB or not. In case there is a new name in the json, then i have to pick that value and save it in DB.

version - 2015.1.OHS.3703.0

i have a json request as follows:

[  
   {  
      "Name":"Billing"
   },
   {  
      "Name":"Lead"
   },
   {  
      "Name":"Coordinator"
   },
   {  
      "Name":"Director"
   },
   {  
      "Name":"Main"
   },
   {  
      "Name":"Marketing"
   },
   {  
      "Name":"Workshop"
   },
   {  
      "Name":"In-House Trainer"
   },
   {  
      "Name":"Committee"
   },
   {  
      "Name":"Facilitator"
   },
   {  
      "Name":"Facilitator"
   }
  ]

Now my code : Controller

ClassMethod CheckMissingRoleName() As %Status
{

#dim newObj As Model.Role
#dim %request As %CSP.Request
#Dim MyStrings As %ListOfObjects 

set inputParms %request.Content
set MyStrings inputParms.data

Set resultu=##class(%ResultSet).%New("%DynamicQuery:SQL")
  Do resultu.Prepare("select Name from Model.Role ")  // 
Do resultu.Execute()
set i=1
while (resultu.Next())
{
set namesArray(i) = resultu.Data("Name")
set i=i+1
  //write namesArray(i)
}

for k=1:1:MyStrings.Size 

for j=1:1:i
{
if MyStrings.GetAt(k).Name '= namesArray(j) ) }
else {  break  }
}
// i is size of array and j is size of above loop i.e coldn't find match, and reached the end
if (j)
{
   set newObj ##class(Model.Role.%OpenId(MyStrings.GetAt(k).ID)
 set newObj.Name=MyStrings.GetAt(k).Name
 // write MyStrings.GetAt(k)
 Do newObj.%Save()
    }
}
return $$$OK
}

After sending the request using Postman, i am getting this error:

{
    "Error": "ERROR #5002: Cache error: <PROPERTY DOES NOT EXIST>zCheckMissingRoleName+2^Controllers.Roles.2 *data,%Library.ListOfObjects"
}

 

and one more thing, how do i print something on the console? Just for debugging

Certifications & Credly badges:
Sudarshan has no Certifications & Credly badges yet.
Global Masters badges:
Sudarshan has no Global Masters badges yet.
Followers:
Sudarshan has no followers yet.
Following:
Sudarshan has not followed anybody yet.