• jpwagner
  • NEWBIE
  • 200 Points
  • Member since 2007

  • Chatter
    Feed
  • 8
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 66
    Replies
Has anyone successfully written callouts to SAP/XI?

I have tried all sorts of combinations, but running into issues:

All my research points that I am doing this correct.  We have tried both self-signed certs and basic username/password authentication.

Setting my stub values:
Stub.inputHttpHeaders_x.put('Authorization','BASIC dnJldmF....W1wcGFzczAx');
--OR--
Blob headerValue = Blob.valueOf(username + ':' + password);//username/password set above String authorizationHeader = 'BASIC '+ EncodingUtil.base64Encode(headerValue);
stub.inputHttpHeaders_x.put('Authorization', authorizationHeader);

We have also tried (separately):
stub.clientCert_x = 'MIIG...';//Where this is the bas64 encoding of the pkc12 version of the cert
stub.clientCertPasswd_x = 'xxxxx';

Nothing seems to get past the security layer.  Has anyone successfully written the outbound message?

 

 

 

 

A little challenge,

 

I have say 100 strings in a list that are in this format: 3 to 5 numbers, a space, a name.  

Example 1: "1234 Product Name One"

Example 2: "12345 Product Name Two"

 

How do I most efficiently remove the 1234 and the space so I just have Product Name? 

 

Result 1: "Product Name One"

Result 2: "Product Name Two "

In sandbox that got upgraded to winter 10.

 

I am trying to return a Database.QueryLocation from the start method.

 

The release notes and the documentation for winter 10 clearly says that I can return either iterable or QueryLocator. But, in my code if  I say something like 

 

global Database.QueryLocator start(Database.BatchableContext ctx)

{

return Database.getQueryLocator('Some query here'); 

 

It does not compile.

  

Ihave a custom field on Account that is a user lookup called "SA Manager."  I also have an "SA Manager User" lookup field on Opportunity that is a user lookup.  Every opportunity related to that account needs to have the SA Manager User field updated when "SA Manager" field is changed on the Account.

 

I created a trigger to update it, but can't seem to get the code to compile.  My IF statement is off and I'm getting the following error:

 

Error: Compile Error: Illegal assignment from Schema.SObjectField to Id at line 13 column 8

 

 

 

trigger UpdateSAMgrOnOppty on Account (after update) { Account acctObj = Trigger.new[0]; IF (acctObj.SA_Manager__r.Id != null && ISCHANGED(acctObj.SA_Manager__r.Id))

User name = [SELECT u.Id, u.Name from User u where u.Id =: acctObj.SA_Manager__r.Id]; for (Opportunity oppty : [Select o.Id, o.SA_Manager_User__r.Id From Opportunity o where o.Account.id = :acctObj.id ]) { oppty.SA_Manager_User__c = name.id ; update oppty; } }

 


Any help is appreciated!

 

I have an Object which the Name field starts with "AO-" Now within that is an autonumber. So the field would say for a record after created is AO-01856. How in an Apex Class just get the number from here and not the AO.

I am trying to create a new record for the child object which relates to the parent object.

Thanks

Hi All,

 

I need to run batch apex in every 2 hours using "batch Apex" faciulity given by SFDC. Please help me with the same.

 

 

regards

Sunil Arora

Currently all my APEX trigger and classes are either version 14.0 or 15.0. I noticed that 17.0 is available in the version control settings. Do I need to update everything? Also, going forward should I use the latest version, would I have metadata issues?

 

Thanks

Is it possible to get report data via apex? So essentially you are requesting the report to run and retrieving the report data in a List of sobjects or something similar? 
Hi all, I have a question. Is is posible to create a custom object using a web service call or apex code? Thank you very much for you help.

I have a business case where I need to display the corresponding input field when a value has been selected. For example: when Phone and fax fields have been selected as to what needs to be added, the cooresponding Phone and fax fields will be displayed. Currently my code is:

 

<apex:actionRegion > <apex:pageblockSection columns="1" > <apex:pageBlockSectionItem > <apex:outputLabel value="What Information needs to be Corrected?" id="thePageBlock1"/> <apex:outputPanel > <apex:inputfield value="{!Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c}"> <apex:actionSupport event="onclick" rerender="thePageBlock1" status="status1"/> </apex:inputField> <apex:actionStatus startText="applying value..." id="status1"/> </apex:outputPanel> </apex:pageBlockSectionItem><apex:pageBlockSectionItem > <apex:outputLabel value="Correct the Information"/> <apex:outputPanel > <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Correct_the_Information__c}"> <apex:actionSupport event="onclick" rerender="thePageBlock" status="status"/> </apex:inputField> <apex:actionStatus startText="applying value..." id="status"/> </apex:outputPanel> </apex:pageBlockSectionItem> </apex:pageblockSection> </apex:actionRegion> <apex:pageBlockSection columns="1" rendered="{!Manufacturing_Design_Sheet__c.Correct_the_Information__c==true}"> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Technical_Phone__c}" /> </apex:pageBlockSection> <apex:pageBlockSection columns="1" rendered="{!And(Manufacturing_Design_Sheet__c.Correct_the_Information__c==true, Manufacturing_Design_Sheet__c.What_Information_needs_to_be_Corrected__c=='Commercial Phone') }"> <apex:inputfield value="{!Manufacturing_Design_Sheet__c.Commercial_Phone__c}" /> </apex:pageBlockSection>

 

 

Any suggestions? Do I need to run the logic to disply the fields in my trigger?

I have a trigger that sends an outbound email when an opportunitylineitem is deleted from a particular opportunity. However my test class is failing saying that "no index id on line 22". any help would be greatly appreciated

 

my trigger:

trigger UnassignedConsultantRemoved on OpportunityLineItem (before delete) {
{
Set<Id> Pricebookentryid = new Set<Id>();

for (OpportunityLineItem OppLineItem : Trigger.old)
{
if (opplineitem.opportunityid =='006R0000003rc72IAA')
{
PricebookentryId.add(opplineitem.pricebookentryid);


Map<Id,String> PricebookEntryMap = new Map<Id, String>();
Map<Id,Datetime> PricebookEntryDate = new Map<Id, Datetime>();


for(Pricebookentry pb:[select id, name, lastmodifieddate from pricebookentry where id IN: pricebookentryID])
{
Pricebookentrymap.put(pb.id,pb.name);
PricebookentryDate.put(pb.id, pb.lastmodifieddate);

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'bkim@dlcinc.com'};
mail.setToAddresses(toAddresses);
mail.setSubject('DLC Consultant removed from Bench');
mail.setUseSignature(false);
string msg = ' <br>';
msg = msg + '<b>' + 'Consultant, ' + pb.name + ' has been removed from the bench on ' + '</i>' + pb.lastmodifieddate;
msg = msg ;
mail.setHtmlBody(msg);

// Send the email
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
}
}
}

 

 

My test class:

 

@isTest 
private class TestOpportunityLineItemDelete {

static testMethod void myUnitTest() {
Account acc = new Account(Name = 'TestAccount', Type = 'Prospect', Industry = 'Banking', Physical_Street__c = 'Test Street',Physical_City__c = 'Los Angeles', Physical_State__c = 'CA', Physical_Zip_Postal_Code__c = '90017', Physical_Country__c = 'USA', Phone = '(888) 999-1234' );
Opportunity opp = new Opportunity(Name= 'Test', accountid = acc.Id, Type = 'CSD Transition', Stagename= 'Won-Engagement in Process', PracticeArea__c = 'Won-Engagement in Process',CloseDate=Date.today(), EngagementStartDate__c = Date.today(), EngagementEndDate__c = Date.today(),Work_Type__c = 'Project',Status__c = 'Full-time', OT_Multiplier__c = 1, DT_Multiplier__c =1 );
OpportunityLineItem olt1 = new OpportunityLineItem(Opportunityid = opp.id,Unitprice= 180.00, Quantity = 1);

try {
insert olt1;
}
catch(DmlException olt)
{
System.debug(olt.getMessage());
}

test.starttest();

ID newid = olt1.id;
delete olt1;
test.stoptest();
}
}

Message Edited by bikla78 on 08-18-2009 11:01 PM

We went Live with SF today, and I'm getting Too many SOQL queries error on a trigger of mine.

 

The trigger is fairly simple in concept in that it takes the ownership of an opportunity and makes certain related objects (or certain objects related to those related objects) and makes the owner of the record the same.

 

In implmentation, I had to do maps and limit the scope of of things with comparisions to keep under the limits and I succeeded until now. 

 

But I'm making no sense of this error message.  At my count there are at most 12 SOQL queries in my code, none in any sort of loop.  So..... how is it adding up to 20?  Is it counting Workflows, Triggers that trigger other triggers, triggers that trigger other triggers that trigger this trigger again?  What are the exception to the rule in which I can't just count the number of potential queries in a given query code to see if I'm going to exceed this SOQL limit?

 

Here's the code:

trigger Opportunity_Ownership_Trigger on Opportunity (after insert, after update) {
    List<String> theIds = new List<String>();
    for(Opportunity opp : Trigger.new) {
          theIds.add(opp.Id);
      }
      boolean updated = false;
     
      List<Order_Detail__c> od_list = [SELECT Id,Opportunity__c,OwnerId,Order__c FROM Order_Detail__c WHERE Opportunity__c IN :theIds];
      for(Order_Detail__c od : od_list) {
        if (Trigger.newMap.get(od.Opportunity__c).OwnerId != od.OwnerId) {
              od.OwnerId = Trigger.newMap.get(od.Opportunity__c).OwnerId;
              updated = true;
        }
      }
      if (updated)
      {
          update od_list;
      }
      Map<Id, Order_Detail__c> od_map = new Map<Id, Order_Detail__c>([SELECT Id,Opportunity__c,OwnerId,Order__c FROM Order_Detail__c WHERE Opportunity__c IN :theIds]);
      Map<Id, Order_Detail__c> od_order_map = new Map<Id, Order_Detail__c>();
      for(Order_Detail__c od : [SELECT Id,Opportunity__c,OwnerId,Order__c FROM Order_Detail__c WHERE Opportunity__c IN :theIds]) {
          if(!od_order_map.containsKey(od.Order__c)) {
              od_order_map.put(od.Order__c,od);
          }         
      }
 
      updated = false;
     
      List<Invoice_Detail__c> id_list = [SELECT Id,Opportunity__c,OwnerId,Invoice__c FROM Invoice_Detail__c WHERE Opportunity__c IN :theIds];
      for(Invoice_Detail__c id : id_list) {
        if (Trigger.newMap.get(id.Opportunity__c).OwnerId != id.OwnerId) {
              id.OwnerId = Trigger.newMap.get(id.Opportunity__c).OwnerId;
              updated = true;
        }
      }
      if (updated)
      {
          update id_list;
      }
      Map<Id, Invoice_Detail__c> id_map = new Map<Id, Invoice_Detail__c>();
      for(Invoice_Detail__c id : [SELECT Id,Opportunity__c,OwnerId,Invoice__c FROM Invoice_Detail__c WHERE Opportunity__c IN :theIds]) {
          if(!id_map.containsKey(id.Invoice__c)) {
              id_map.put(id.Invoice__c,id);
          }
      }
     
      updated = false;
      theIds = new List<String>();
    for(Order_Detail__c od : od_list) {
          theIds.add(od.Id);
      }
      List<Order_Release__c> or_list = [SELECT Id,OwnerId,Order_Detail__c FROM Order_Release__c WHERE Order_Detail__c IN :theIds];
      for(Order_Release__c or_item : or_list) {
        if (od_map.get(or_item.Order_Detail__c).OwnerId != or_item.OwnerId) {
              or_item.OwnerId = od_map.get(or_item.Order_Detail__c).OwnerId;
              updated = true;
          }
      }
      if (updated)
      {
          update or_list;
      }
     
      updated = false;
      theIds = new List<String>();
    for(Order_Detail__c od : od_list) {
          theIds.add(od.Order__c);
      }     
      List<Sales_Orders__c> o_list = [SELECT Id,OwnerId FROM Sales_Orders__c WHERE Id IN :theIds];
      for(Sales_Orders__c o : o_list) {
        if (od_order_map.get(o.Id).OwnerId != o.OwnerId) {
              o.OwnerId = od_order_map.get(o.Id).OwnerId;
              updated = true;
          }
      }
      if (updated)
      {
          update o_list;
      } 
         
      updated = false;
      theIds = new List<String>();
    for(Invoice_Detail__c id : id_list) {
          theIds.add(id.Invoice__c);
      }     
      List<Invoice_Object__c> i_list = [SELECT Id,OwnerId FROM Invoice_Object__c WHERE Id IN :theIds];
      for(Invoice_Object__c i_item : i_list) {
        if (id_map.get(i_item.Id).OwnerId != i_item.OwnerId) {
              i_item.OwnerId = id_map.get(i_item.Id).OwnerId;
              updated = true;
          }
      }
      if (updated)
      {
          update i_list;
      }       
}

 

Additionally these triggers support that trigger by invoking it appropriately, but do not error out:

trigger Opportunity_Ownership_Trigger_Order_Detail on Order_Detail__c (after insert, after update) {
    List<String> theIds = new List<String>();
    if (Trigger.isInsert) {
        for (Order_Detail__c od : trigger.new) {
            if (od.Opportunity__c != null) {
                theIds.add(od.Opportunity__c);   
            }   
        }
    }
    else if (Trigger.isUpdate) {
        for (Order_Detail__c od : trigger.new) {
            if (Trigger.oldMap.get(od.Id).Opportunity__c != od.Opportunity__c) {
                if (od.Opportunity__c != null) {
                    theIds.add(od.Opportunity__c);     
                }
            }
        }
    }
    List<Opportunity> opp_list = [SELECT Id FROM Opportunity WHERE Id IN :theIds];
    update opp_list;
}

trigger Opportunity_Ownership_Trigger_Invoice_Detail on Invoice_Detail__c (after insert, after update) {
    List<String> theIds = new List<String>();
    if (Trigger.isInsert) {
        for (Invoice_Detail__c od : trigger.new) {
            if (od.Opportunity__c != null) {
                theIds.add(od.Opportunity__c);   
            }   
        }
    }
    else if (Trigger.isUpdate) {
        for (Invoice_Detail__c od : trigger.new) {
            if (Trigger.oldMap.get(od.Id).Opportunity__c != od.Opportunity__c) {
                if (od.Opportunity__c != null) {
                    theIds.add(od.Opportunity__c);     
                }
            }
        }
    }
    List<Opportunity> opp_list = [SELECT Id FROM Opportunity WHERE Id IN :theIds];
    update opp_list;
}

I'm writing a trigger that will cause some data updates to happen when an Opportunity has certain products added or changed.

 

I think the trigger should run on Opportunity (after insert, after update), but I can't seem to access data like Opportunity.OpportunityLineItem[x].productName when triggering on the opportunity.

 

If OpportunityLineItems aren't a child of Opportunity, how does one access that data?  I guess I'm not approaching this correctly and don't understand the Opportunity object yet.

 

Thanks,

Kevin

Hi all,

 

I think I must be misunderstanding something about some of the governor limits.

 

Here's a quick example of something I'd like to understand better:

 

I have a trigger that does a bunch of calculations on insert and update of a custom object and inserts some new records based on those calculations.  When I split up my ~52,000 record initial dataset, and load (via the APEX Data Loader)~13,000 records 4 times, I have no governor limit breaches.  When I load all 52,000 at once, it breaks the Script statement governor limit. 

 

I thought the APEX data loader batches it's loads into 200, so how is this possible?

Message Edited by jpwagner on 04-13-2009 11:37 PM