Updating an array element using updatecallback throw bad request error

367 views
Skip to first unread message

sivak...@gmail.com

unread,
Aug 19, 2014, 10:54:55 AM8/19/14
to suppor...@runmyprocess.com
Hi,

I want to update an element inside an array using the updatecallback method. I want to do it this way as I don't want to do a wholesale update on the document. I am using the updatecallback javascript API and I am getting the bad request error while the same query works in my mongodb shell.

I am using this MongoDB format:

db.collection.update( { <query selector> }, { <update operator>: { "array.$.field" : value } } )

Here is my query:

Http Query:
https://live.runmyprocess.com/live/2215365968/object/col_society_evaluation/?P_query=%7B%22memberno%22%3A%2200744920%22%2C%22nomination_class%22%3A%222015%22%2C%22societyid%22%3A%22MEMRA024%22%2C%22profiletype%22%3A%22evaluator%22%2C%22nominationsassigned.nominations.packageid%22%3A%221394134282704%22%7D&P_multi=false&P_mode=TEST&method=PUT

Javascript code:
col_society_evaluation.updateCallback({"memberno":selectedevalmemno, "nomination_class":nomclass, "societyid":societyid, "profiletype":"evaluator", "nominationsassigned.nominations.packageid":nompackageid}, { $set: { "nominationsassigned.nominations.$.assignmentstatus" : "unassigned" } }, updateEvaluatorsSuccess, updateEvaluatorsFailure);

P_query value from the console:
P_query {"memberno":"00744920","nomination_class":"2015","societyid":"MEMRA024","profiletype":"evaluator","nominationsassigned.nominations.packageid":"1394134282704"}

Post data:
{"$set":{"nominationsassigned.nominations.$.assignmentstatus":"unassigned"}}

Since the same query works in my mongodb shell, I am confused.

Thanks a lot in advance for your help!

Regards,
Siva

Dimitri MELCHIOR Pro

unread,
Aug 19, 2014, 11:21:40 AM8/19/14
to RunMyProcess Support Forum
Hi Siva,

ou are not alloed to set the JSON directly into the method..

Could you try with that code?

var P_query = {};
P_query.memberno = "00744920";
P_query.nomination_class = "2015";
P_query.societyid = "MEMRA024";
P_query.profiletype = "evaluator";
P_query.nominationsassigned = {};
P_query.nominationsassigned.packageid = "1394134282704";

var P_object = {};
P_object.$set = {};
P_object.$set.nominationsassigned = {}
P_object.$set.nominationsassigned.nominations = {};
P_object.$set.nominationsassigned.nominations.$ = {};
P_object.$set.nominationsassigned.nominations.$.assignmentstatus = "unassigned";

col_society_evaluation.updateCallback(P_query, P_object, updateEvaluatorsSuccess, updateEvaluatorsFailure);


Best regards.

--

Dimitri MELCHIOR

PreSales Consultant

     

Fujitsu RunMyProcess user? Please add a review on GoogleApps Marketplace

Afin de contribuer au respect de l'environnement, merci de n'imprimer ce message qu'en cas de nécessité.
Be environmentally friendly: do not print this email unless it is entirely necessary.



--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "RunMyProcess Support Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum...@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.
To view this discussion on the web visit https://groups.google.com/a/runmyprocess.com/d/msgid/supportforum/2cce1909-86d6-40cf-8c34-5c7dc3028f6c%40runmyprocess.com.
For more options, visit https://groups.google.com/a/runmyprocess.com/d/optout.

sivak...@gmail.com

unread,
Aug 19, 2014, 1:44:41 PM8/19/14
to suppor...@runmyprocess.com
Hi Dimitri,

Thanks for your quick response.

It does not throw and error but it does not update the document either. Here is my root document. I want to update the "notificationstatus" of an array element with unassigned without doing the wholesale update.

Can you help me to get the query for the listcallback?

Also, I noticed that, a double dot notation is throwing an error.

{
"citation": "for contributions to integrated high-speed and radio-frequency silicon devices and components.",
"memberno": "44444444",
"nomination_class": "2015",
"invitestatus": "Accepted",
"nominationsassigned": {
"nominations": [{
"packageid": "1393470473367",
"assignmentstatus": "assigned",
"notificationstatus": "notified",
"evaluation_instanceid": "0e6e4b54-2578-11e4-aec8-123139225512",
"conflict": {
"status": "yes",
"reason": "some reason sdjgdokfjg"
}
},
{
"packageid": "1393470872845",
"assignmentstatus": "assigned",
"notificationstatus": "notified",
"evaluation_instanceid": "4b0835d0-2578-11e4-aa5d-1231380c7265",
"conflict": {
"reason": "ftutfy",
"status": "yes"
}
},
{
"packageid": "1393469683231",
"assignmentstatus": "assigned",
"evaluation_instanceid": "fbc83c30-26fe-11e4-aa5d-1231380c7265",
"notificationstatus": "notified",
"conflict": {
"status": "yes",
"reason": "some reason"
}
},
{
"packageid": "1394134282704",
"assignmentstatus": "assigned",
"evaluation_instanceid": "7a0314a0-271b-11e4-b72c-12313b0614f1",
"notificationstatus": "notified"
}]
},
"lastname": "Burghartz",
"firstname": "Joachim",
"profiletype": "evaluator",
"insertdate": "2014-08-16 12:34:40",
"email": "x...@ieee-dev.org",
"invitetaskurl": "https://live.runmyprocess.com/live/2215365968/form/38623df4-2563-11e4-aa5d-1231380c7265/2/0",
"notifiedtime": "1408395975155",
"technicalareas": {
"techareavalue": ["Computer and robot vision",
"Manufacturing automation",
"Motion and path planning",
"Sensor design,integration, and fusion"]
},
"secondary_email": "",
"societyname": "IEEE Robotics & Automation Society",
"societyid": "MEMRA024"
}

Thank you!

Regards,
Siva

sivak...@gmail.com

unread,
Aug 19, 2014, 4:06:03 PM8/19/14
to suppor...@runmyprocess.com, sivak...@gmail.com
Hi Dimitri,

To make this simple, I did some changes to my schema to remove one layer of object. Now here is the new document structure. Now I need to update the assignmentstatus inside the nominations array.

I am still getting the bad request.

{
"citation": "for contributions to decoding and detection that include reliability information",
"email": "peteradam....@ieee-dev.org",
"firstname": "PeterAdam",
"insertdate": "2014-08-19 15:26:44",
"invitestatus": "Accepted",
"invitetaskurl": "https://live.runmyprocess.com/live/2215365968/form/e4d338d0-27d6-11e4-aec8-123139225512/2/0",
"lastname": "Hoeher",
"memberno": "00799619",
"nomination_class": "2015",
"profiletype": "evaluator",
"secondary_email": "",
"societyid": "MEMC016",
"societyname": "IEEE Computer Society ",
"technicalareas": {
"techareavalue": ["Computer education",
"Applications"]
},
"nominations": [{
"packageid": "1401891319015",
"assignmentstatus": "assigned",
"notificationstatus": "new"
}]
}

Thanks for your help!

Regards,
Siva

Dimitri MELCHIOR Pro

unread,
Aug 20, 2014, 5:50:16 AM8/20/14
to RunMyProcess Support Forum, Sivakumar Venkatachalam
Hi Siva,

We are working internally to propose you solutions. Neverthelesss, I just realized that I made a mistake in the previous query sent to you. Could you retry with that one?

var P_query = {};
P_query.memberno = "00744920";
P_query.nomination_class = "2015";
P_query.societyid = "MEMRA024";
P_query.profiletype = "evaluator";
P_query.nominationsassigned = {};
P_query.nominationsassigned.nominations.packageid = "1394134282704";

var P_object = {};
P_object.$set = {};
P_object.$set.nominationsassigned = {}
P_object.$set.nominationsassigned.nominations = {};
P_object.$set.nominationsassigned.nominations.$ = {};
P_object.$set.nominationsassigned.nominations.$.assignmentstatus = "unassigned";

col_society_evaluation.updateCallback(P_queryP_object, updateEvaluatorsSuccess, updateEvaluatorsFailure);

Anyway, we will get back to you.

Best regards.

--

Dimitri MELCHIOR

PreSales Consultant

     

Fujitsu RunMyProcess user? Please add a review on GoogleApps Marketplace

Afin de contribuer au respect de l'environnement, merci de n'imprimer ce message qu'en cas de nécessité.
Be environmentally friendly: do not print this email unless it is entirely necessary.



Regards,
Siva

--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "RunMyProcess Support Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum...@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.

sivak...@gmail.com

unread,
Aug 20, 2014, 10:56:22 AM8/20/14
to suppor...@runmyprocess.com, sivak...@gmail.com
Hi Dimitri,

I am getting a javascript error with the P_query you sent. Here is the error:

P_query.nominationsassigned.nominations is undefined

That is bcos we dont define the nominations in the code below:

P_query.nominationsassigned = {};
P_query.nominationsassigned.nominations.packageid = "1394134282704";


But anyway, to make it simple, I have updated the schema. I have removed the intermediate nominationsassigned object and made the nominations an array into the root object. Here is the sample root document:


{
"citation": "for contributions to decoding and detection that include reliability information",
"email": "peteradam....@ieee-dev.org",

"firstname": "PeterAdam",
"insertdate": "2014-08-19 15:26:44",
"invitestatus": "Accepted",
"invitetaskurl": "https://live.runmyprocess.com/live/2215365968/form/e4d338d0-27d6-11e4-aec8-123139225512/2/0",
"lastname": "Hoeher",
"memberno": "00799619",
"nomination_class": "2015",
"profiletype": "evaluator",
"secondary_email": "",
"societyid": "MEMC016",
"societyname": "IEEE Computer Society ",
"technicalareas": {
"techareavalue": ["Computer education",
"Applications"]
},
"nominations": [{
"packageid": "1401891319015",
"assignmentstatus": "assigned",
"notificationstatus": "new"
}]
}

Thank you!

Regards,
Siva

Dimitri MELCHIOR Pro

unread,
Aug 21, 2014, 11:07:22 AM8/21/14
to RunMyProcess Support Forum, Sivakumar Venkatachalam
Hi Siva,

What do you mean when saying "Also, I noticed that, a double dot notation is throwing an error."

Best regards.



--

Dimitri MELCHIOR

PreSales Consultant

     

Fujitsu RunMyProcess user? Please add a review on GoogleApps Marketplace

Afin de contribuer au respect de l'environnement, merci de n'imprimer ce message qu'en cas de nécessité.
Be environmentally friendly: do not print this email unless it is entirely necessary.


sivak...@gmail.com

unread,
Aug 21, 2014, 2:33:48 PM8/21/14
to suppor...@runmyprocess.com, sivak...@gmail.com
Hi Dimitri,

That is not valid anymore since I have removed the intermediate object. So one dot notation is enough now. I just tested it now, I am seeing this error as part of the response.

{"error":"com.mongodb.WriteConcernException: { \"serverUsed\" : \"live-bo-14:27017\" , \"err\" : \"not okForStorage\" , \"code\" : 12527 , \"n\" : 0 , \"lastOp\" : { \"$ts\" : 1408645311 , \"$inc\" : 3} , \"connectionId\" : 137935 , \"ok\" : 1.0}"}


Regards,
Siva

sivak...@gmail.com

unread,
Aug 25, 2014, 1:22:02 PM8/25/14
to suppor...@runmyprocess.com, sivak...@gmail.com
Hi Dimitri,

Do we have any update on this?

Thank you!

Regards,
Siva

Reply all
Reply to author
Forward
0 new messages