• matt.byler
  • NEWBIE
  • 75 Points
  • Member since 2012

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 14
    Replies

Hi 

 

I am trying to use my docusign recipient status to update my quote and opportunity status and was informed we would have to use apex trigger to do so. I do not have any idea on how to write this code. Any help would be appreciated.

I have the following trigger I need to deploy to production but have only been able to get 66% test coverage. 

 

trigger createworkorder on Opportunity (after update)
{
if(trigger.new[0].StageName=='closed won'&&(trigger.old[0].StageName<>'closed won'))
{
Work_Order__c obj=new                               Work_Order__c(Opportunity__c=trigger.new[0].id,Stage__c='New',Account__c=trigger.new[0].AccountId);

insert obj;
List<Case> ll=new List<Case>();
for(OpportunityLineItem la : [SELECT PricebookEntry.Product2.Name from OpportunityLineItem where opportunityId =: Trigger.new])
{
String ss= String.ValueOf(la.PricebookEntry.Product2.Name);
case c1=new case(Status='new',Subject='Fulfillment for'+' '+ss,Work_Order__c=obj.id);
ll.add(c1);
}
insert ll;
}
}

 

Can someone help me with this test code?

I currently have a trigger that when an opportunity gets marked closed won it creates a record in our custom object and inserts a case under the custom object. We would like the cases to be inserted based on what products are on the opportunity. Example: If the opportunity has one product the trigger will create one case. However if it has more than one product it would insert one case for each product. Is this possible to do?

I do not know if this is possible or not but decided to post and see if anyone has done this before. What I am trying to do is when a user clicks on a button it validates that certain fields are not blank. If there are blank fields it should disply an error message quite similar to validation rules. Let me know if there is any way I can do this.

I have the following trigger that needs to have a test method before I can deploy it and would like any advice on how to do this.

 

 

trigger createworkorder on Opportunity (after update)
{
if(trigger.new[0].StageName=='closed won'&&(trigger.old[0].StageName<>'closed won'))
{
Work_Order__c obj=new Work_Order__c(Opportunity__c=trigger.new[0].id);
insert obj;
case c1=new case(Status='new',Subject='Create Product Cases for Work Order',Work_Order__c=obj.id);
insert c1;
}
}

I have the following code that I am trying to write a test method for and am not able to figure out how to make this work.

 

public class MyExtension
{
public Work_Order__c wo{get; set;}
opportunity opp;

public MyExtension(ApexPages.StandardController controller)
{
opp=[select id,accountId from opportunity where id=:controller.getId()];
wo = new Work_Order__c();
wo.Opportunity__c=opp.id;
if(opp.AccountId!=null)
wo.Account__c=opp.AccountId;

}
public PageReference save()
{
insert wo;

PageReference woPage = new ApexPages.StandardController(wo).view();
woPage.setRedirect(true);
return woPage;
}


public PageReference cancel()
{

PageReference woPage = new ApexPages.StandardController(wo).view();
woPage.setRedirect(true);
return woPage;
}
}

 

This code runs a visualforce page that creates a record for a custom object relating back to the opportunity and the opportunity account. Custom object is called a work order. Let me know if there is anything I can do to test this.

We have a custom object that is related to the Opportunity object. Upon the opportunity being closed won we would like to trigger the creation of the related object called Work Order. After the Work Order is created we would like to have a case created under that work order. I have tried using triggers and apex code and I cant seem to get this to work correctly. Any ideas?

I have a VF page that creates work orders when you click a custom button on the opportunities page. I want to transfer opportunity name and account to the work order through the page but it is throwing an error. Any ideas how to retain information from a previous page????

I have the following trigger I need to deploy to production but have only been able to get 66% test coverage. 

 

trigger createworkorder on Opportunity (after update)
{
if(trigger.new[0].StageName=='closed won'&&(trigger.old[0].StageName<>'closed won'))
{
Work_Order__c obj=new                               Work_Order__c(Opportunity__c=trigger.new[0].id,Stage__c='New',Account__c=trigger.new[0].AccountId);

insert obj;
List<Case> ll=new List<Case>();
for(OpportunityLineItem la : [SELECT PricebookEntry.Product2.Name from OpportunityLineItem where opportunityId =: Trigger.new])
{
String ss= String.ValueOf(la.PricebookEntry.Product2.Name);
case c1=new case(Status='new',Subject='Fulfillment for'+' '+ss,Work_Order__c=obj.id);
ll.add(c1);
}
insert ll;
}
}

 

Can someone help me with this test code?

I currently have a trigger that when an opportunity gets marked closed won it creates a record in our custom object and inserts a case under the custom object. We would like the cases to be inserted based on what products are on the opportunity. Example: If the opportunity has one product the trigger will create one case. However if it has more than one product it would insert one case for each product. Is this possible to do?

I have the following trigger that needs to have a test method before I can deploy it and would like any advice on how to do this.

 

 

trigger createworkorder on Opportunity (after update)
{
if(trigger.new[0].StageName=='closed won'&&(trigger.old[0].StageName<>'closed won'))
{
Work_Order__c obj=new Work_Order__c(Opportunity__c=trigger.new[0].id);
insert obj;
case c1=new case(Status='new',Subject='Create Product Cases for Work Order',Work_Order__c=obj.id);
insert c1;
}
}

We have a custom object that is related to the Opportunity object. Upon the opportunity being closed won we would like to trigger the creation of the related object called Work Order. After the Work Order is created we would like to have a case created under that work order. I have tried using triggers and apex code and I cant seem to get this to work correctly. Any ideas?

I have a VF page that creates work orders when you click a custom button on the opportunities page. I want to transfer opportunity name and account to the work order through the page but it is throwing an error. Any ideas how to retain information from a previous page????