Create Record from Portal Pages

Posted by rgoyal@test.com on 31-Oct-2014 01:10

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.

All Replies

Posted by Chandrasekhar Gontla on 31-Oct-2014 01:28

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

Posted by rgoyal@test.com on 31-Oct-2014 01:50

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.

Posted by Chandrasekhar Gontla on 31-Oct-2014 01:57

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

Posted by rgoyal@test.com on 31-Oct-2014 02:26

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

Posted by Chandrasekhar Gontla on 31-Oct-2014 03:02

Hi rgoyal,

Yes. You can use it.

Please try it

Thanks and Regards,

Chandra.G

Posted by rgoyal@test.com on 31-Oct-2014 05:17
Hi Chandra.G,

I tried this:
function my_callback(arr) {

}
var x = new Array();
x["name"]="API Created";
var newId = rbf_createRecord("objIntName", x, true,my_callback);
rbv_api.print("Created record with id: "+newId);


and getting this error:
Error "rbf_createRecord" is not defined...

[collapse]
On Fri, Oct 31, 2014 at 1:33 PM, Chandrasekhar Gontla <bounce-cgontla@community.progress.com> wrote:
Reply by Chandrasekhar Gontla

Hi 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.




--
Rohit Goyal   Software Developer  I  Astrea IT Services   rgoyal@astreait.com  +91-9654373714 l  www.astreait.com  l 
[/collapse]
Posted by Orchid Corpin on 31-Oct-2014 08:54

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

Posted by Orchid Corpin on 31-Oct-2014 09:04

Revision:

rbv_api....this is a server-side API and cannot run in portal pages unless use in #EVAL[]

Posted by Orchid Corpin on 13-Nov-2014 16:24
Hi rgoyal,

Is the issue has been fixed? or do you have followup questions related to this thread?
Thank you.

Regards,
Orchid
This thread is closed