I'm new to Rollbase and I'm trying to create records from a Portal page. Though I tried Object Script API method createRecord like as:
var x = new Array();
x["amount"]=1000;
x["name"]="From API";
var newId = rbv_api.createRecord("ABC", x);
rbv_api.print("Created record with id: "+newId);
But it is returning 'null' always.
I will really appreciate any kind of help.
Thanks in advance.
Hi,
The code that you have mentioned above is working for me.
Could you please check the integration names of fields and object once again?
Thanks and Regards,
Chandra.G
Hi Chandrasekhar,
Thanks for your reply.
Let me explain you what I have done in the portal page. I simply add the below javascript :
Now I checked with other object :
#EVAL[
function f1() {
var g = new Array();
g["name"]="01-TEST";
var newId = rbv_api.createRecord("ObjInteName", g);
rbv_api.print("Created record with id: "+newId);
}
f1(); ]
I have View, Create, Edit and Delete permissons perhaps I'm running out with this error:
ERROR: Error Query API: permission denied for both current user and API user.
Can you help.
Hi rgoyal,
We have enable Query API permissions for that object.
Go to 'ObjInteName' object definition-> Permissions section. Click on 'Edit Permissions' button.
Enable 'Query API' permissions by clicking on 'Select All' option beside 'Query API' and save.
Try the same scenario by launching portal page once again.
Let me know if you have any questions.
Thanks and Regards,
Chandra.G
Yes. You were right Chandra.G . I enabled all the Query API permisssions and now I'm not getting this new error however I'm still failing with 'null' at the time of launching the page.
I've noticed that we have some browser side script available like: rbf_createRecord(objName, fieldMap, useIds, callback)
Can we use it.
Thanks
Hi rgoyal,
Yes. You can use it.
Please try it
Thanks and Regards,
Chandra.G
Reply by Chandrasekhar GontlaHi rgoyal,
Yes. You can use it.
Please try it
Thanks and Regards,
Chandra.G
Stop receiving emails on this subject.Flag this post as spam/abuse.
Hi,
First can you make sure that the portal has enabled AJAX Calls.
If the page required login portal visitor then check "for authenticated portal visitors"
if the page is viewable by anyone then check "for non-authenticated portal visitors".
In your code, "rbv_api.print("Created record with id: "+newId);" will cause an error, this is a server-side API and cannot run in portal pages, you can use console.log() instead.
Here are some code revisions:
<script> function my_callback(arr) { //output the new record's ID console.log("NEW ID: "+arr); } var x = new Array(); x["name"]="API Created"; rbf_createRecord("objIntName", x, true, my_callback); </script>
Hope this will help.
Regards,
Orchid
Revision:
rbv_api....this is a server-side API and cannot run in portal pages unless use in #EVAL[]
Hi rgoyal,
Is the issue has been fixed? or do you have followup questions related to this thread?
Thank you.
Regards,
Orchid