Problem in calling Apex function

I have created one Row Action in Table and calling apex function from snippet. But it is not able to call the Apex function. Weird thing is that i am not getting error after clicking row action icon.

Can somebody help to resolve it?

Class -
public with sharing class MyApexController{
public static List getUnReadAlerts(Id alertId){
// Logic
return List;
}
}

Page -

<apex:page docType=“html-5.0” readOnly=“true”
standardController=“SObject” extensions=“MyApexController”>
<skuid:page page=“skuidPage”/>
</apex:page>

Snippet -

var $ = skuid.$,
args = arguments[0],
item = args.item,
list = args.list,
model = args.model;

var currentUserModel = skuid.model.getModel( ‘NewModel’ );
var alertRecord = currentUserModel.getFirstRow();
var alertId = currentUserModel.getFieldValue( alertRecord, ‘Id’ ) ;
currentUserModel.abandonAllRows();
alert(‘Point1’);
var myUnReadAlerts = MyApexController.getUnReadAlerts(alertId);
currentUserModel.adoptRows(myUnReadAlerts);
alert(‘Point2’);

I am able to get the first alert , but not second.

HI Sumeet, it looks like you might need to add the @RemoteAction annotation to your apex class, so that its exposed to javascript in the page - as per this post: https://community.skuid.com/t/calling-apex-function so your apex class becomes: public with sharing class MyApexController{ @RemoteAction public static List getUnReadAlerts(Id alertId){ // Logic return List; } } This also assumes you’ve got your skuid page deployed in visualforce using the skuid:page method, which it looks like you do. Hope that works for you.

Thanks for quick help Greg!

But still my controller is not getting called and getting undefined in following variable.

var myUnReadAlerts = MyApexController.getUnReadAlerts(alertId);

Alert(
myUnReadAlerts) —> Undefined

Do you have any clue on this?

Hi Greg, 

Now i am able to call the apex method , but my model is not getting updated.

currentUserModel.abandonAllRows(); – it is not updating model


That looks like it should work. Have you done a console.log() before and after to confirm whether its changed? ie console.log('Model length before = '+currentUserModel.length); currentUserModel.abandonAllRows(); console.log('Model length after = '+currentUserModel.length); The other method you might want to try is currentUserModel.emptyData(); as outlined here https://community.skuid.com/t/abandonrow-not-updating-the-model-in-page-2-of-wizard