Skip to main content

Hi Team.

I want to monitor the console log on click the standard save button on skuid page. Could you please let me know how to add console log without javascript code snippet used ?

Thanks

Can’t do this without. The snippet would be very easy though.


Hi Rajat, I would recommend replacing the standard Save button in your page with one that will run multiple actions. Doing that, you can easily add a snippet to run console.log(“Save clicked”);  message, or something like this:


var params = argumentsm0],<br>$ = skuid.$;<br>console.log(params);

Thanks Mark and Vachon, For your prompt response, @Mark, I have create new custom button replaced the standard save button and it works well 🙂

But here I am getting one trouble, I want to enable/disable the custom button just like the standard save behaviour on row actions basis.

On create new row, I am able to enable the custom button, but how to enable the button on edit row action?

On Rendered options, I am getting below Row property : - 

a. Is New Rocord
b. has Unsaved Changes
c. Is Existing Record in database
d. Is unsaved clone of existing record
e. Is Marked for deletion


Thanks







Option b works as once you create or edit a row, it will have unsaved changes.


Thanks Man 🙂

It works 


Hi Mark and Vachon,

Could you please suggest us the below point : - 

I was trying to include alert and console log in snippet.

But it shows Object Object] in alert. I want to popup the error if any otherwise will alert “Successfully saved”.

var params = argumentsm0];
$ = skuid.$;
window.alert(‘Result’+ params.);
console.log(params);


Rajat,

Change your window.alert to->  window.alert(params);

Thanks,

Bill


Hi Bill,

Result came same :  - Object Object].

But i want to display the content, if successfully saved row otherwise display the error message causing the error.

Thanks


Rajat,

Are you using the standard ‘Save’ action in Skuid? Or is it custom (i.e. your ‘save’ button calls a javascript snippet to save the model/models?

Thanks,

Bill


Hi Bill,

We are using custom save button to perform below multiple actions : - 

a. Save changes in model
b. Run Javascript snippet

Thanks


Bill,

In console log, It displays proper params with proper row content. but in alert It shows [Object Object]

Thanks




Can you provide your snippet code.


Hi Vachon,

Below are the code snippet : - 

var params = argumentss0];
$ = skuid.$;
window.alert(‘Result’+ params.);
console.log(params);

Thanks


Hmmm … the console log won’t provide anything unless it’s associated to an action with context. Is the button in a Page Title or Button Set? If Button Set, did you set the model for it?


Hi Rajat,

I’ve noticed with console.log() if you log both a string like ‘Result’ + an object like params together in one log, you’ll see the sObject Object].  When you put an object like that into an alert, you’re asking to display the whole object and all its layers, but the Alerts aren’t built to understand how to do that.

There is probably one item inside params that you’re wanting to display, like ‘label’ or ‘result’ or ‘total success.’ You should be able to use something like 


window.alert('Result'+ params.result);


Also, in the snippet you posted, there should not be a period after params. 

I’d try window.alert(‘Result’+ params); as well, to see if that has an effect. 



Hi Mark,

I tried the same, still It says [Object Object]

Requirement : - 

1. I want to debug the row after save, using alert.

2. Console loge is doing good, It shows me all info related to the newly saved record.

3. But I want to print popup on the page when customer click save button, If it successfully saved OR Id created for the record then print the message “Successfully saved” otherwise print “Error Message” 


On click custom save button, I am performing below action items in these order : - 

1. Save changes in model
2. Run Javascript code snippet (For Console log and alert purpose only)

Thanks








Rajat,

Try this in your snippet:

var params = arguments[0],
$ = skuid.$;
var opp=skuid.$M(‘Opportunity’);
console.log(opp);

alert("opp model-> " + objToString(opp));


function objToString (obj) {
    var str = ‘’;
    for (var p in obj) {
        if (obj.hasOwnProperty(p)) {
            str += p + ‘::’ + obj p] + ’

';
        }
    }
    return str;
}

See the details here-> https://stackoverflow.com/questions/5612787/converting-an-object-to-a-string

Thanks,

Bill


Hi Rajat,


I’m interested to see if Bill’s suggestion will work for you. I also wanted to offer a declarative way, based on what you described here. When you set up a save button that uses the Save Model Changes action, you can set up an On-Error action, that will display an error message that you can define, or run other actions. There’s also a checkbox to rollback changes to all models if the save fails - that could be helpful if you’re saving several models at once.


Here’s the XML for a simple page showing the on-error action, in case it’s helpful:



<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" useviewportmeta="true" showheader="true">
<models>
<model id="Account" limit="1" query="false" createrowifnonefound="true" datasource="salesforce" sobject="Account">
<fields>
<field id="Name"/>
<field id="Description"/>
<field id="Phone"/>
<field id="Industry"/>
</fields>
<conditions/>
<actions/>
</model>
</models>
<components>
<buttonset model="Account" uniqueid="sk-2rdw-289">
<buttons>
<button type="multi" label="Save Account" uniqueid="sk-2rdw-294">
<actions>
<action type="save" rollbackonanyerror="true">
<models>
<model>Account</model>
</models>
<onerroractions>
<action type="blockUI" message="There was an error saving this record." timeout="3000"/>
</onerroractions>
</action>
</actions>
</button>
</buttons>
</buttonset>
<basicfieldeditor showheader="true" showsavecancel="false" showerrorsinline="true" model="Account" uniqueid="sk-2rdw-243" mode="read">
<columns>
<column width="50%">
<sections>
<section title="Section A" collapsible="no">
<fields>
<field uniqueid="sk-2rdw-266" id="Name"/>
<field uniqueid="sk-2rdw-267" id="Phone"/>
</fields>
</section>
</sections>
</column>
<column width="50%">
<sections>
<section title="Section B" collapsible="no">
<fields>
<field uniqueid="sk-2rdw-278" id="Description"/>
<field uniqueid="sk-2rdw-279" id="Industry"/>
</fields>
</section>
</sections>
</column>
</columns>
</basicfieldeditor>
</components>
<resources>
<labels/>
<javascript/>
<css/>
<actionsequences uniqueid="sk-2rdw-259"/>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</skuidpage>