function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
emuelasemuelas 

javascript button issue

Hi ,

I have an object Order(master) and it has a child  object Order Lines

I have a custom list Javascript button  on the Order Lines object ,"Create Purchase Order" which has a javascript code that validates the selected records and  redirects to the "New" page of another object "Purchase_order__c" with some values from the order prepopulated.

 

When i create the purchase order i need to have  some sort of summary of the order line records selected( a popup of selected records) that  the  user can view before going on to the new purchase order form.

 

How should i do this?

Can i use a visualforce page that displays the selected record details?


But how do i integrate this with my existing Javascript button just before the "new purchase order" form?

I dont want to have a visualforce new edit form.....


What is the easiest way to do this with the  existing code and validations?

 

Is there anyway in the button where i first redirect to the vf page ( which should appear as a popup)

 

Existing List button code:

 

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}
var selectedRecords = {!GETRECORDIDS($ObjectType.Order_Line__c)};
if (selectedRecords[0] == null)
{
alert("Please select at least one Order Line.");
}
else
{
var SelectedIds='';
for(var i=0;i < selectedRecords.length; i++)
{SelectedIds+="'"+selectedRecords[i]+"',";}
SelectedIds=SelectedIds.substring(0,SelectedIds.length - 1);
var sfQuery="Select Id,Name,sup__c from Order_line__c where ID in ("+SelectedIds+")";
var result=sforce.connection.query(sfQuery);
var bProcess= true;
var records = result.getArray("records");
for (var r = 0; r < records.length; r++)
{
if(records[0].sup__c!=records[r].sup__c)
bProcess=false;
}
if(bProcess)
{

var newRecords = [];
for (var n=0; n<selectedRecords.length; n++)
{
var c = new sforce.SObject("Order_line__c");
c.id = selectedRecords[n];
c.checked__c = 1;
c.status__c='Purchased';
newRecords.push(c);
}
result = sforce.connection.update(newRecords);

*************************************************************************

//Something here that will display the selected records details /////

*************************************************************************

window.location.href ="/a0I/e?retURL=%2Fa0I%2Fo"+
"&CF00NR0000000cvG6={!Sales_Order__c.Name}"+
"&CF00NR0000000cvEt={!Sales_Order__c.Default_Warehouse__c}" +
"&00NR0000000cvEU={!Sales_Order__c.Order_Date__c}"+
"&CF00NR0000000cvEZ={!$User.FirstName } {!$User.LastName}"+
"&CF00NR0000000cvEK="+ records[0].sup__c+
"&CF00NR0000000cz5b="+ records[0].sup__c;
}
else
{
alert("Sorry ,You can create Purchase Orders from the same Supplier only!");
}
}

 

 

b-Forceb-Force

Hey,

 

If I am not wrong, I had provide above Javascript solution to you for your previous threads,

 

Now your need is want to show some records , on some Pop-ups , before navigating to "New Purchase Order " form.

 

If you are comfortable with jQuery library,

we can show some cool pop-up to display selected records,

and then navigate to "New Purchase Order" page

 

Let me know,you can mail me at balasahebwani@gmail.com

 

Thanks,

Bala

 

 

emuelasemuelas

Thank you Bala

 

 

I have sent you an email from my id :sabah@mvp.ae

emuelasemuelas

Hi Bala, please help me with this