Skip to main content
Nintex Community Menu Bar
Question

Problem in calling Apex function

  • July 10, 2024
  • 4 replies
  • 1 view
  • Translate

Forum|alt.badge.img+4

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.

Did this topic help you find an answer to your question?

4 replies

Forum|alt.badge.img+8

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.

Translate

Forum|alt.badge.img+4

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?

Translate

Forum|alt.badge.img+4

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


Translate

Forum|alt.badge.img+8

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

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings