Change value in table on Button click in Acumatica - javascript

I am creating a Scan In and Out form in Acumatica as a custom screen. They are two separate screens and both are just a standard form.
They are both setup as follows: One field that is a selector where you select the Key ID of the data row you want to modify such as a Work Order. Once you click Scan In it will change the value of a field in that data row for the Key ID you selected let's say, the status field saying that it is being processed for Scan In button click and closed for the Scan Out button click.
My question is, is it possible to do this with just a click event. I mean the save button commits changes to the database but this does not have a save and is only changing one field of a specific data row.
If anyone has suggestions or can point me in the right direction that would be great! Again this is all in Acumatica so I feel the Graph or View will have to be modified?

Once in my company we did something similar, i know this is not the best option based on acumatica way, but what we did is to execute a direct SQL query from the action (in your case the click button) to update/insert something in database. I think the best option for you would be use Ajax, but i don't know if acumatica has this functionality.

In your action that is changing the status of the row, after changing the status, you can call an update to your view (ViewName.Update(targetRow)) that is used to populate the page with the information you are looking at. After you can programmatically trigger a page save using this.Actions.PressSave().

Related

set up form option as default in a drop down

I have created a driven database drop down menu on my website. It sends the selected value by the user to the database to be checked and returns a specific item.
Everything works perfectly now but I'm trying to pre select the first value so that the user will have the first option as default and can add it to cart directly and they also can choose a different size. So far, I tried 'selected' inside the option in the drop down but it doesn't do anything but displays the value when the page loads.
One last thing to mention, I'm using Ajax function to submit selected value and return result from the database.
I can think of two ways for this.
When the page is requested, make a call to your DB in your server-side code to store that value beforehand.
Use javascript's onload event to select the value as a part of a client-side script. You can use this answer as reference.

how do i display user input on the same page, with the option to delete

Good day programmers. I am very new to jsp/javascript but this site has helped me a lot so far, but i can use some more help or guidance for a problem i am having.
I am making a web app for creating and saving recipes. For my "add recipe" process, i have the user enter a recipe name, they are then directed to another page where they can choose an ingredient from a dropdown (populated from a sql db), enter a quantity, and then click a button to ad another ingredient.
What i wish to do is have the ingredient selected and the amount displayed to the user on the same page where they are choosing the ingredients. I also want to add a button at the end of the "print out" that allows the user to remove that ingredient.
So far i am thinking that i should use a table and have a row created when the user adds an ingredient, then use the deleterow() method to remove that ingredient if desired.
Does anyone think this can work? or have a better solution.
PS: i am very new to jsp and javascript.
thanks in advance for any assistance rendered.
You can use ajax to achieve this. For that using jQuery will make you writing a lot less number of lines of code.
So it will work like this, they have entered the recipe name. Now using onblur on that field input, you load the dropdown of ingredients and give them option of entering quantity and selecting the ingredient with a button to save that data.
When they click on the button to save, after it getting saving into the database, you make an ajax call to load the recent added item with a button to delete it and when they click on delete, you make another ajax call to the database to delete it.
Here is a guide to ajax on javaScript
https://developer.mozilla.org/en-US/docs/AJAX

How to match a button push in a table of buttons to specific data on the server?

If you believe the title can be edited please feel free to do so.
I have small web app that's used to search for entries in a database. You are given a table of entries, and you can click on one of those entries to expand it down (accordion) to view more details.
I want to add a few buttons to manipulate the entries in different ways, however, I am not sure how to pass information from the button click to a javascript function that I can use to identify and change the data in the database. Pretty much there may be 50 rows in the table, but I want to identify which one the button was pushed in (specifically something that can be used to uniquely identify the row in the database, not in the HTML table).
How/what should I pass to a function when the button is clicked?
I apologize if this is too broad, I have absolutely no idea where to start, any guidance is welcome.
Everything depends on how you submit button click to the server. If you do this with ajax call then the simplest solution will be to add entry id to the request. You can add this id to the table row with data-entry-id="{id_from_table}" and then retrieve it in js. If your buttons are simple links then you can change it to button/input with type submit and wrap it with form which would have hidden field of entry_id.

Changing database values in an HTML table

I have written a control panel for managing devices, however as we have imported hundreds of them, there are a lot of values that need to be manually set. I have an overview page that shows the most import information and I am looking at some way to allow the end-user to change those values by clicking them.
Right now they are just text in TD cells pulled from the Database. Would it be possible to do something like double clicking the cell changes it to a drop-down box of options and then when deselected it automatically saves it to the database?
I have been searching Google and Stack Overflow but I am not even sure what to search for to get an idea of how to accomplish this.
To do this you must (short version):
Handle click event on your value from table
Change(hide text and display input) text for input with setted value
Handle blur event on your input
If some changes have been made, send Request (by AJAX) to your php actions which save value in database. Or do nothing if there were no changes.
Change(hide input and display text ) input to text

Hide/Disable Edit button based on column's Values in Sharepoint 2010

I have a column that has 2 Categories, Done and Pending. I would like to Hide/Disable edit button once the user selects an item and if that item has a Status column of "Pending".
I would like to know how can this be done, whether in visual studio 2010 or ECMA Scripts.
I know this question is old but if someone still needs the answer:
Create a custom action in visual studio like this:
https://msdn.microsoft.com/en-us/library/office/ff408060(v=office.14).aspx
This hides the button you want, now you can set a condition via enabledscript parameter to choose in which case the button should be hidden:
Just add this code after </CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="HideEditRibbon"
CommandAction="javascript:return true;" EnabledScript="javascript:checkIfNeedsToBeHidden();" />
</CommandUIHandlers>
<CustomAction Id="yourJsReference" Location="ScriptLink" ScriptSrc="yourJsFile.js"></CustomAction>
If you need this in List-Ribbon, Edit and DisplayForm, you need to make 3 Custom Actions and change the Location-Part and maybe your js-code.
If you want to use an out of the box edit form then you're not going to do this with server side code; you'd need an entirely custom edit form to do that.
This means using Javascript on the edit page, which is fragile, and doesn't prevent users from saving the data if they know what they're doing.
The input field for every column will have a 'title' attribute with the column name. JQuery can find the element with title='column name' rather easily, so that's how you'll know if you need to hide the save button. The save button isn't quite as easy to get to. You could try getting the input with type=button and value=save.
If it's important to have actual security around this, so that no matter what someone can't edit an item in this state then you can use an event receiver on the ItemUpdating event. Just check the properties of the item and use the properties.Cancel = true; (or something like that) so that even if they disable your JavaScript and save the event anyway, it won't get saved. If you need help adding an event receiver or getting it working just ask.
Edit: In your comment that you say you just want to prevent access to the edit form entirely under certain conditions. For that, I'd make a new webpart/user control and add it to the edit page. In that section you can fetch the appropriate item (the ID of the item will be a query parameter) and see if the page should be 'viewable'. If not, then you can redirect to another page.
Another addition to the above would be attempting to edit the list view such that there is no edit link for certain items. This would be substantially harder, and I doubt it would even be possible (practically) with out of the box webparts. You would need to have an entirely custom list view page in order to control which items have links to an edit page. (Others feel free to correct me here.)

Categories