Skip to main content
Nintex Community Menu Bar
Question

Error: Remote action function is not defined

  • July 9, 2024
  • 6 replies
  • 20 views

Forum|alt.badge.img+4

Remote action function is working for existing records, but it’s not working for the new records. Getting an error saying that remote action function is not defined.

6 replies

Forum|alt.badge.img+17
  • Nintex Employee
  • July 9, 2024

Can you post a screenshot of the error you are getting,  and describe what steps the user is taking, what the expected outcome would be and what actually happens? 

Thanks. 


Forum|alt.badge.img+4
  • Author
  • July 9, 2024

Yeah Sure Rob, Here is the Screenshot.

Step1: I am trying to create a new “Event” record and I am having an action ‘snippet’ which does the ‘Save’ for me. It is throwing me an error saying that remote action function is not defined. In this case I am expecting to create a “Event” record.

Step 2: When I was trying to edit the existing “Event” record it works. Here I am using the same snippet to do the ‘Save’ action for. (I mean I am using the remote action function which i was using in step1.)


Forum|alt.badge.img+9

Can you post your full snippet?


Forum|alt.badge.img+4
  • Author
  • July 9, 2024

Here it is,

skuid.snippet.registerSnippet(‘save.Event’, function() {    var params = arguments[0],
        model = params.model,
        editor = params.component.element.editor,
        row = params.row,
        $ = skuid.$;

    var requiredFieldsEntered = validateRequiredFields(model, editor);
    if(!requiredFieldsEntered) {return false;}

    var eventId = row.EventID__c === undefined ? null : row.EventID__c;
    OdataExtension.saveEvent(
        eventId,
        JSON.stringify(row),
        function(result, event) {
            console.log(event.status);
            if(event.type === ‘exception’) {
                console.log(“exception”);
                console.log(event);
                return false;
            } else if(event.status) {
                console.log('Save successful: ’ + result);
                console.log(changedRows);
            } else {
                console.log(event.message);
            }
        }
    );
});


Forum|alt.badge.img+9

Where is “OdataExtension” coming from? Is that another snippet on your page? I don’t see it defined in this snippet… 


Forum|alt.badge.img+4
  • Author
  • July 9, 2024

Sorry my bad, OdataExtension is nothing but a apex class. where I am having some RET calls going on.

Here is the piece of code for that,

@RemoteAction    global static String saveEvent(String recordGuid, String jsonString) {
Boolean isNewRecord = Guid.isEmpty(recordGuid);
        recordGuid = isNewRecord ? Guid.createGuid() : recordGuid;
        
        jsonString = jsonString.replace(‘__c’, ‘’);
EventMastering.Event event = (EventMastering.Event)JSON.deserialize(jsonString, EventMastering.Event.class);
event.EventID = recordGuid;
System.debug(event);

        buildHttpRequest(‘POST’, EVENTS_ENDPOINT, isNewRecord, recordGuid, JSON.serialize(event));
        
        return recordGuid;
    }


GUID: Is also one of the apex class I have, here is the logic behind the GUID.

global class Guid {    global static Boolean isEmpty(String guid) {
        return guid == null || guid == ‘00000000-0000-0000-0000-000000000000’;
    }
    
    global static String createGuid() {
        Blob b = Crypto.GenerateAESKey(128);
        String h = EncodingUtil.ConvertToHex(b);
        String guid = h.SubString(0,8) 
            + ‘-’ + h.SubString(8,12) 
            + ‘-’ + h.SubString(12,16) 
            + ‘-’ + h.SubString(16,20) 
            + ‘-’ + h.substring(20);
        
        return guid; 
    }
}


Thanks,
Goutham