Add button to list view

Hi there,

I need to add a button in list view that appears alongside each of the records that when clicked, takes the data from that records fields and creates an invoice with the same fields.

I think I can handle the creation of an invoice and all the fields fine, however I was wondering how do I create a button in list view, and how do I make sure it links with the record?

Thanks

For adding button in list view you can inject js or make use of display function in view.list.php


<script>
$( ".class" ).after( $( "Button" ) );
</script>

Add button in list view

I don’t mean adding a new button at the top or bottom of the page, I mean adding a button within the list in list view.

I.E within the table of records one of the fields is buttons.

i think this may help you i haven’t tried

try it and if its working than do post back

button to list view

I’ve seen that, however I am trying to add this button to the AOS_Invoices Module not the Contacts module, and the Invoices module seems to be layer out differently and therefore does not have the function present that’s listen in that document.

I managed to do it!
I ended up using a process_record hook to add in the buttons and then use javascript to control the existing mass update function and it all works really well!

Great to hear this!

Could you please share the full details of how you achieved it for the future benefit of all?

Thanks

Sure!

I first added the status field to mass_update by changing the 0 to 1 in vardefs for that module.

I used this post to create the logic:
http://developer.sugarcrm.com/2012/10/15/conditional-formatting-on-cases-list-view-and-dashlets/
Only difference is except is instead of setting the field to be an image etc…I created links with specific IDs.

I then created a custom ‘view.list.php’ file to create add javascript to the links but only for the list view of that particular module.
In the file I used javascript as follows: when a user clicks on one of the buttons in the table row the checkbox in the given row is ticked, the status option is selected and the update function is ran. View the code below:

$(document).ready(function(){
	$(".movetoenquiry-button").click(function(){
        var checkboxes = $(this).parent().siblings().children();
        checkboxes.prop("checked",!checkboxes.prop("checked"));
		$("#mass_status").val(1);
		return sListView.send_mass_update("selected", "Please select at least 1 record to proceed.")
    })
    $(".movetojob-button").click(function(){
        var checkboxes = $(this).parent().siblings().children();
        checkboxes.prop("checked",!checkboxes.prop("checked"));
		$("#mass_status").val(4);
		return sListView.send_mass_update("selected", "Please select at least 1 record to proceed.")
    })
	$(".cancel-button").click(function(){
        var checkboxes = $(this).parent().siblings().children();
        checkboxes.prop("checked",!checkboxes.prop("checked"));
		$("#mass_status").val(10);
		return sListView.send_mass_update("selected", "Please select at least 1 record to proceed.")
    })
	$(".archive-button").click(function(){
        var checkboxes = $(this).parent().siblings().children();
        checkboxes.prop("checked",!checkboxes.prop("checked"));
		$("#mass_status").val(9);
		return sListView.send_mass_update("selected", "Please select at least 1 record to proceed.")
    })
})