Alert in view record for Netsuite - netsuite

I have been trying to get a alert in Netsuite for view mode but can't get it for customer record.
Though when I tried to get the alert for the edit record then I got it but I want it for view.
I tried client script, user event script and also workflow. But all support only for edit. Can I get the alert by any means for the view record option.
Thanks
Gladiator

One workaround that I've done is to add a custom field of type 'Inline HTML' to the customer form. Then during the beforeLoad event you can check if type == 'view' and update the custom field's value with the HTML that is needed to display the alert.

Basically form.setScript used to work with SS1 but there was no (not hacked) API access to Netsuite's alerts
SS2.0 gives nice access to the alert system but it doesn't load in view mode unless you take a supported action (clicking a button)
See this answer for a sample with SS2 that loads your script and shows an integrated alert.
SS2.0 Display Message on Record

Thanks Mike, Michoel and Bknights.
Here is the solution to the problem.
Create an inline html field on the customer form.
Since the field does not store value nlapiSetFieldValue for before load function works absolutely fine.
Below is the snippet of the working code.
function before_load(type)
{
if (type == 'view')
{
var pass_value = "<html><body><script type='text/javascript'>window.alert('Hello World!!!')</script></body></html>";
nlapiSetFieldValue("custentity25", pass_value); //custentity25 is the id of Inline HTML field we created
}
}
Note : The "" used should be different then the one used in the HTML code which is ''. If same are used then there will be an error.

You need to use a User Event Script, and in the before load event, set a Client Script via form.setScript(). In your "injected" Client Script, you can display the alert.

Related

How to show a button on Customer Form only in view mode?

I created a button to redirect to an external page on the customer form on NetSuite through SuiteScript and it shows only in EDIT mode, but I want to show it only in VIEW mode. What can I do to fix it?
I tried some script lines but didn't work. The button is working properly redirecting to the external page, the problem is only about showing in the correct place, which is ONLY on VIEW mode.
You need to add context type in the user event script beforeLoad(context),
just add this line in the before load function at top.
Note- in Function if you using beforeLoad(context) then use context else use sriptContext.
if (sriptContext.type !== sriptContext.UserEventType.VIEW)
return;
It will work.
Thanks.

In NetSuite How to Hide custom subtab using client script?

is it possible to hide custom subtab on field change event of client script in Netsuite?
If there is any solution avilable then help me.
You will need to get the subtab's id from the source. In my basic example below, I hide the shipping tab on a transaction when entity is changed.
function hideTabFieldChanged(type, name, linenum) {
if (name == 'entity'){
$('#shippinglnk').hide();
}
}

How to disable add/edit/delete of sublist suitescript

How can I disable editing of the sublist using Suitescript user event (before load) in netsuite?
I also need to disable the inline editing.
Thank you.
You don't really need to disable editing before load, because no one can interact with sub-lists at this point. Sub-lists are like linked to the main record which means they load as the main record object loads, so the best way to prevent them from being edited is on the DOM.. which means making a form script or client-script (form preferably).
-If you know which form is used by the record go to it, else go to the record and look for "customize form" on the upper-right menu on the blue area.
-Then click on custom code.
-Add a script for "Validate Line Function" to prevent that line from being edited.
-Use the NetSuite example as a base, to prevent the line from editing you just have to return false.
function sampleValidateLine(type)
{
if ( (nlapiGetCurrentLineItemValue('item', 'custcol_service_item') == true) &&
(!nlapiGetCurrentLineItemText('item', 'custcol_service_rep')) )
{
alert("You must choose a Service Rep for this service item.");
return false;
}
return true;
}
Ideally in NetSuite you would restrict this based on permissions. For custom records, you can disable inline editing, and you can disable child record editing. The help documentation has this to say about it:
Check the Allow Child Record Editing box to allow records of this type
to be edited directly when they display as child records in a sublist
on a parent record.
https://system.netsuite.com/app/help/helpcenter.nl?topic=CARD_-29 see item 14.
You can also use form object to achieve the same. See sample code below:-
var form = scriptContext.form;
var serviceItemColumn = form.getSublist({id: 'timeitem'}).getField({id: 'item'});
serviceItemColumn.updateDisplayType({ displayType : 'disabled' })

xpages: compute Confirm Action confirmation text does not work in XPiNC

I'm using Notes/Domino 8.5.3. I've added a button control to an xpage. The button uses a Confirm Action to display a client-side prompt to the user before continuing with the next action defined for the button. When I use static text for the Confirmation Text for the Confirm Action, the confirmation prompt is displayed. However, when I change the Confirmation Text to be computed, and retrieve the text from a profile document, the confirmation prompt it not displayed at all in XPiNC. The confirmation prompt with the computed confirmation text is displayed just fine in a browser. Is there a work-around for this issue with XPiNC?
Following is the code I'm using in the Confirm Action to get the text for the prompt:
var server = database.getServer();
var dbProfile:NotesDocument = database.getProfileDocument("DBProfile", "");
var msg = dbProfile.getItemValueString("ContactsInitUpdatePrompt");
return msg;
To further my comments, this is a work around I use the below code for an app that uses the bootstrap extension library on the web but uses basic functionality with xpinc.
If the values for xPinc are different you could make the confirm action different in the browser and in the client.
if (#ClientType()== "Notes")
{
<action>;
}
else{
<action>;
}
I think that profile documents are a bad idea in xPages though. Having to restart HTTP to get a new value ruins the point I think. Almost better to hard code values at that point. I think you can set application scope to handle the work of profile documents. But then application scope in xpinc is just on the current machine as the server is the client.

Modifying sharepoint edit dialog

I have successfully created a feature in sharepoint that modifies the existing edit dialog and adds a custom button to it like this.
and I am aware that I can pass back data when the user clicks the custom button like this.
<CommandUIHandlers>
<CommandUIHandler Command="ActivateUser" CommandAction="/_layouts/MyFeature/MakeUserActive.aspx?ListID={ListId}&ItemID={ItemId}&ItemUrl={ItemUrl}&ListUrlDir={ListUrlDir}" />
</CommandUIHandlers>
As detailed here
I can now handle the list item and perform my required actions on it BUT given that this button has been added in the modify context (IE: Inside the sharepoint edit item dialog) what if you want to save changes to the data itself?
To me it seems like using your custom button would always mean losing any changes the user has made to the data. Is there a way around this?
Good question!
You actually already linked to the solution: Right now you are simply redirecting the user by using a URL as your CommandAction: CommandAction="/_layouts/MyFeature/MakeUserActive.aspx?ListID={ListId}&ItemID={ItemId}&ItemUrl={ItemUrl}&ListUrlDir={ListUrlDir}"
This if course redirects the user to another page without saving the current entry. What you want to do is use Javascript as linked in the MSDN article:
CommandAction="javascript:alert('here be dragons');"
You can either work the the SharePoint Javascript object model here and use something like SP.ListOperation.Selection.getSelectedItems(); or you could use complete custom code.
From your aspx page name I can see you want to "make a use active" (btw: wouldn't "ActivateUser.aspx" be nicer?). If this simply means setting a property in another list you could do that with the SharePoint OM, if it is some custom stuff you would need a webservice which you can call from JavaScript and "activate the user" like that. You can of course always access the current form and pass on the values the user entered. Or you could create a custom save button which does some stuff (activate user) before saving.
Lastly: You can also have postbacks in your custom button where you could do anything you'd like.

Resources