• DEV SFDC
  • NEWBIE
  • 20 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 14
    Replies
Hi there,
i have a java script button on the Opportunity Deatil page  which which  clicked it should create a new Project Manager and
2. it should get the list of Quote Items  from the opportunity and then it has to  take the id created from the Project Manger  then finally it has to create project Summary records from QuoteLineItems
Here is the code that i worked with:

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/22.0/apex.js" )}
var connection = sforce.connection;
var oid="{!Opportunity.Id}";
var pm = new sforce.SObject("Project_Manager__c");
alert('Opportunity ID'+oid);
pm.Opportunity__c='{!Opportunity.Id}';
var result=sforce.connection.create([pm]);
alert('Project Manager Insert successful'+pm);

var result = sforce.connection.query("Select PricebookEntry.Product2Id,UnitPrice,Quantity,Description From OpportunityLineItem Where OpportunityId = '{!Opportunity.Id}'");
var records = result.getArray("records");
alert(records);
var CreateRecords=[];

if(records[0]==null)
alert('no records to insert');
for(var i=0;i<records.length;i++)
{
   var PS=new sforce.SObject("RTC__Project_Summary__c");
   PS.Ordered__c=records[i].Quantity;
   PS.Project_ID__c='pm.id';         // i think Not getting the Project Manager Id from the above step
   PS.Generic_Product_Name__c=records[i].PricebookEntry.Product2Id;
   PS.Line_Description__c=records[i].Description;
   PS.Total_Sales_Price__c=records[i].UnitPrice;
   UpdateRecords.push(PS);
  
}
sforce.connection.create([CreateRecords]);

problem: Project manager is inserted but the project summary records are not created when clicked on the button.

Any help would be much appreciated.

Many Thanks
Hi there,
i am wroking with the javascript detail page button.

My question here is we have a Detail page button on the Work stage tasks  which when clicked should pick the Project reference from the Work stage task record and it should update with the custom filed "Project Reference" on the Task.
Any help would be much appreciated.

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/22.0/apex.js" )}
var Wid="{!Work_Stage_Tasks__c.Id}";
alert('First HI'+Wid);

var query="Select id,Project_Reference__c from Task where WhatId='{!Work_Stage_Tasks__c.Id}'";
var records=sforce.connection.query(query);
var records1=records.getArray("records");
alert(records1);
var UpdateRecords=[];

for(var i=0;i<records1.length;i++)
{
var NewTask=new sforce.SObject("Task");
NewTask.Project_Reference__c='{!Work_Stage_Tasks__c.Project_Reference__c}';
UpdateRecords.push(NewTask);
}
result=sforce.connection.update([UpdateRecords]);


Many Thanks inadvance!!
Hi there,
My requirement is that we have a Custom Detail Page button on Opportunity , when we click on the button it should create a new record on Custom object. Here is the code snippet that i worked with but when we clicked on the button it is smiply showing error that " A PROBLEM WITH THE ONCLICK JAVASCRIPT BUTTON OR LINK :{fault code: Invalid_Type,SObject Type abc__c is not supported. Be sure to append __c if you are using custom object.

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/22.0/apex.js" )}
var connection = sforce.connection;
var ab= new sforce.SObject("abc__c");
ab.Opportunity__c='{!Opportunity.Id}';
sforce.connection.create([ab]);


Any help would be much appreciated.
Many Thanks


Hi there,
i have a java script button on the Opportunity Deatil page  which which  clicked it should create a new Project Manager and
2. it should get the list of Quote Items  from the opportunity and then it has to  take the id created from the Project Manger  then finally it has to create project Summary records from QuoteLineItems
Here is the code that i worked with:

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/22.0/apex.js" )}
var connection = sforce.connection;
var oid="{!Opportunity.Id}";
var pm = new sforce.SObject("Project_Manager__c");
alert('Opportunity ID'+oid);
pm.Opportunity__c='{!Opportunity.Id}';
var result=sforce.connection.create([pm]);
alert('Project Manager Insert successful'+pm);

var result = sforce.connection.query("Select PricebookEntry.Product2Id,UnitPrice,Quantity,Description From OpportunityLineItem Where OpportunityId = '{!Opportunity.Id}'");
var records = result.getArray("records");
alert(records);
var CreateRecords=[];

if(records[0]==null)
alert('no records to insert');
for(var i=0;i<records.length;i++)
{
   var PS=new sforce.SObject("RTC__Project_Summary__c");
   PS.Ordered__c=records[i].Quantity;
   PS.Project_ID__c='pm.id';         // i think Not getting the Project Manager Id from the above step
   PS.Generic_Product_Name__c=records[i].PricebookEntry.Product2Id;
   PS.Line_Description__c=records[i].Description;
   PS.Total_Sales_Price__c=records[i].UnitPrice;
   UpdateRecords.push(PS);
  
}
sforce.connection.create([CreateRecords]);

problem: Project manager is inserted but the project summary records are not created when clicked on the button.

Any help would be much appreciated.

Many Thanks
Hi there,
i am wroking with the javascript detail page button.

My question here is we have a Detail page button on the Work stage tasks  which when clicked should pick the Project reference from the Work stage task record and it should update with the custom filed "Project Reference" on the Task.
Any help would be much appreciated.

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/22.0/apex.js" )}
var Wid="{!Work_Stage_Tasks__c.Id}";
alert('First HI'+Wid);

var query="Select id,Project_Reference__c from Task where WhatId='{!Work_Stage_Tasks__c.Id}'";
var records=sforce.connection.query(query);
var records1=records.getArray("records");
alert(records1);
var UpdateRecords=[];

for(var i=0;i<records1.length;i++)
{
var NewTask=new sforce.SObject("Task");
NewTask.Project_Reference__c='{!Work_Stage_Tasks__c.Project_Reference__c}';
UpdateRecords.push(NewTask);
}
result=sforce.connection.update([UpdateRecords]);


Many Thanks inadvance!!
Hi there,
My requirement is that we have a Custom Detail Page button on Opportunity , when we click on the button it should create a new record on Custom object. Here is the code snippet that i worked with but when we clicked on the button it is smiply showing error that " A PROBLEM WITH THE ONCLICK JAVASCRIPT BUTTON OR LINK :{fault code: Invalid_Type,SObject Type abc__c is not supported. Be sure to append __c if you are using custom object.

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/22.0/apex.js" )}
var connection = sforce.connection;
var ab= new sforce.SObject("abc__c");
ab.Opportunity__c='{!Opportunity.Id}';
sforce.connection.create([ab]);


Any help would be much appreciated.
Many Thanks