When I try to access a value that has not been edited by the user I get an error as the parameter does not exist unless edited in the Gutenberg editor. I would like the parameter to be saved even if it's the default. Is that possible. As a workaround I declare the default value both in Javascript and in Php like below which is not ideal. Hope someone can help!
$formLink = isset($block['attrs']['link']) ? $block['attrs']['link'] : 'Default value';
Related
I want to pass a selected value of a combobox into a java Method. All the posts I see refer about using HttpServletRequest and getParameter function to pass the value, but my problem is, I need the value as a string passed into a Java Method, that already exists. Any pointers how to do it?
I have seen some references of doPost method, but that really doesn't help me, as all I need is the value passed into a customized java method and use it. Any help would be deeply appreciated. I'm stuck on this for several hours.
Any clarification or extra information required, please let me know.
<SCRIPT>
function sendParam(){
var item= document.Form.item[document.Form.item.selectedIndex].value
//I need to send this value to the server side java code and process further
}
</SCRIPT>
I did it through action class.
<SCRIPT>
function sendParam(){
var item= document.Form.item[document.Form.item.selectedIndex].value
//I need to send this value to the server side java code and process further
var url = "/urlToActionClass"
document.Form.acton = url;
document.Form.submit();
}
</SCRIPT>
now the value is passed into java which I read in the action class and used it in the required Java function.
I am new to netsuite scripting using javascript. I like to ask, how can I set field mandatory to false using javascript.
Hope that someone can help me.
Note :
If you use nlapiGetField(fieldname) in a client script to return a nlobjField object, the object returned is read-only. This means that you can use nlobjField getter methods on the object, however, you cannot use nlobjField setter methods to set field properties.
However you can use
nlapiSubmitRecord(item_obj, true, true); to ignore mandatory fields on a record.
For more details check out the included parameters in the method.
nlapiSubmitRecord(record, doSourcing, ignoreMandatoryFields);
You are using the correct methods, but setMandatory is not supported in a client script. You can instead try using the exact same code in a User Event, Before Load event handler.
Contrary to the documentation, the nlobjField returned by nlapiGetField is not read-only. Some of the setter methods still work (e.g. setDisplayType) on the client side. You can experiment with which ones do and do not work, but setMandatory is confirmed as not supported on the client side.
Using SS2.0 on a client script you can make it mandatory with this code:
var newSupervisorField = context.currentRecord.getField('custrecord_new_supervisor');
newSupervisorField.isMandatory = true;
This is what worked for me based on the input from #erictgrubaugh and #user3627301
function fieldChanged(type,name){
var metodPayment=nlapiGetFieldText('field_id_to_check');
if ((name == 'field_id_to_monitor_for_change') && (metodPayment=='Financing')) {
var field1 = nlapiGetField('field_id_to_be_disabled');
field1.setDisplayType('disabled');
}
}
You can set mandatory using SuiteScript 2.0 though although it does not works in 1.0.
Below, is an example snippet using client script on customer record
var currentRecord;require(['N/currentRecord'], (currentRecord) => {
var field = currentRecord.get().getField('comments');
field.isMandatory = true;
})
Maybe my answer was already late but for others that came across this post, this is how I do it via client script.
nlapiSetFieldMandatory('yourFieldId', true);
This was already tested because I am using this often. Though some says you cannot set fields to mandatory via client but you can. I did not find any docs about this on netsuite docs though.
Is it possible to differentiate how documents open in a view on an XPage, depending on the status of a document using the getComponent("programmaticname").getValue() method?
If the status of the document is "Sent" then I want it to open in Edit mode. If the status of the document is "Reviewed" then I want it to open in Read Only mode.
I would like to compute the "openDocAsReadOnly" property in my view. Could someone show me what that code would look like?
This is a working example:
<xp:viewPanel
rows="30"
id="viewPanel1"
var="rowData">
<xp:this.facets>
<xp:pager
...>
</xp:pager>
</xp:this.facets>
<xp:this.data>
<xp:dominoView
var="view1"
viewName="yourView">
</xp:dominoView>
</xp:this.data>
<xp:viewColumn
id="viewColumn2"
displayAs="link"
columnName="Reviewer"
openDocAsReadonly="#{javascript:rowData.getColumnValue('Status') === 'Responded'}">
</xp:viewColumn>
It is important that
viewPanel has var="rowData" so openDocAsReadonly can reference to current row with rowData....
view column Status has not only "Status" as title but as Programmatic use name too
If all works fine then the URL of your Reviewer column should end with &action=openDocument if Status is "Responded" and &action=editDocument for all other cases.
Maybe the cause for you having trouble to get it to run is much easier: use for test "Responded", not "Reviewed". In your former question you told Status is called "Reviewed", so answers use this. But, your picture here shows "Responded".
Make sure you define a variable name in your viewPanel at All Properties >> data >> var (rowData is a frequently used variable name for that)
This variable holds an object of type NotesXspViewEntry, so it knows a method called .getColumnValue(colName:String), where colName is your Notes view column's programmatic name (I assume it's named "Status").
In consequence your openDocAsReadonly property could hold a code like this:
rowData.getColumnValue("Status")=="Responded"
EDIT:
sorry maybe made a mistake here; probably it doesn't work due to a wrong timing. Instead you could try to override the standard url link by defining it in the viewColumn's pageUrl property. A quick test revealed a code like this (I followed Knut Herrmann's observation):
var d = entry.getColumnValue("Status");
var a="editDocument";
if(d=="Responed") {
a="openDocument"
}
"/yourDocXpage.xsp?documentId=" + entry.getUniversalID() + "&action=" + a
Not really sure though whether this is the best of all solutions...
I have this dropdown list for a Model's property (Currency) in my View to which I have associated a JavaScript onchange function.
The goal of such function is to update some other field's (Rate) value according to a Dictionary property from the model (which maps Currencies to their Rate).
<td>
#Html.DropDownListFor(model => model.Currency, new SelectList(ViewBag.CurrencyList, "Code", "Code"), new {onchange="update(this)"})
#Html.ValidationMessageFor(model => model.Currency)
<script type="text/javascript">
function update(elem) {
// alert("Currency changed!")
document.getElementById("#Html.IdFor(model => model.Rate)").value = '#Model.Currencies[<I_WISH_I_COULD_PUT_A_JS_VARIABLE_IN_HERE>]'
}
</script>
</td>
I want that "I_WISH_I_COULD_PUT_A_JS_VARIABLE_IN_HERE" to be elem.value, but I get a syntax error as the JS variable is interpreted as a literal.
I can't seem to call an HTML helper with a Javascript value in it.
My goal is to update an EditorFor field according to the value selected in the combo box. but probably there's something wrong with my approach?
Any help would be appreciated.
You're thinking about this the wrong way. HTML, CSS and JavaScript are output of your ASP.NET MVC web application project. JavaScript can't influence your web application the way you're trying above. There's no live connection between your MVC web application and JavaScript that somehow magically respond to one another.
To get this to work, I would place the values within #Modal.Currencies in some sort of JavaScript array. Then use that array to locate the value you need (with the JavaScript variable) to update the element with.
As I said in my comment, my approach didn't make sense at all as I was mixing server-side code with client-side.
I used ajax inside my function update(elem) to retrieve the correct value and update the correspondent field:
$.ajax({
type: "GET",
url: "Currency?code=" + elem.value,
success: function (msg) {
document.getElementById(RateId).value = msg;
}
});
I hope this might help someone in the future. Cheers.
I have document.form1.submit() in javascript. I want to know how it's received in code behind. In which class, in which method? Something like that. Coz I want to get the value inside a textbox to store it in session. And do i need an actual "submit" button for this to work? This really confuses me.
If i put it like this:
function CallSubmit() {
var thetext = document.getElementById('textbox1').value;
document.form1.submit(thetext);
}
will I be able to pass the value of textbox1 to a specific method in code behind if it has, like, a receiving variable? I mean, how do i get the value of textbox1?
By the way, I'm trying to do this before the page unloads. Because I need to store the text from textbox1 so that I can re-assign that value back after the page refreshes.
You can get the post back values on code behind using the 'Form' as
Request.Form["textbox1"]
and if you read this Request.Form you get all data from post
Comments.
In asp.net we general avoid to use direct the Request.Form and we use asp.net controls that all ready handle the post values.
For example if you use an asp:TextBox with ID=textBox1 then you read the post from textBox1.Text
and if you like to read it using the Request.Form you need to call the Request.Form[textBox1.UniqueID]
The textBox1.UniqueID is the name value on the html control, and the name used for the post back.