• sfdc_oleg
  • NEWBIE
  • 0 Points
  • Member since 2012
  • salesforce.com

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


Hi all,
I'm trying to work through the Force.com workbook and during the "Call an Apex Class Method Using a Button" example, after going through all the steps, when I click the button, I get an error:

{faultcode:'soapenv:Client', faultstring:'No operation available for request
{http;//soap.sforce.com/schemas/package/InvoiceUtilities}
renumberLineItems, please check the WSDL for the service.',}

In my developer instance, I tested the Apex code in the developer console and it returns successfully.  I did research on google, and thought that it was either a permissions issue (I added everyone to the Apex class, no difference), or a Namespace prefix issue (i have namespace prefix 'bpavlyk;).  I confirmed that a WSDL was generated.

The code is straight out of the workbook (pages 79-81) but with add of prefix bpavlyk__ to custom fields and objects.

Here is the Apex class:

global with sharing class InvoiceUtilities {
    
	// Class method to renumber Line Items for a given Invoice number.
	// Returns a string that indicates success or failure.
	webservice static String renumberLineItems(String invoiceName) {

    // create a copy of the target Invoice object and it's Line Items
    bpavlyk__Invoice__c invoice = [Select i.Name, (Select Name From bpavlyk__Line_Items__r ORDER BY Name) 
                            From bpavlyk__Invoice__c i 
                           Where i.Name = :invoiceName LIMIT 1];

    // loop through each Line Item, renumbering as you go
    Integer i = 1;
    for (bpavlyk__Line_Item__c item : invoice.bpavlyk__Line_Items__r) {
      item.Name = String.valueOf(i);
      System.debug(item.Name);
      i++;
    }

    // update the Line Items in one transaction, rollback if any problems
    // and return error messages to the calling environment
    try {
      database.update(invoice.bpavlyk__Line_Items__r);
    }
    catch (DmlException e) {
      return e.getMessage();
    }

    // on success, return a message to the calling program
    return 'Line items renumbered successfully.';
  }
}
 Here is the Javascript OnClick behind the button:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
var result = sforce.apex.execute("InvoiceUtilities","renumberLineItems",{"invoiceName":"{!bpavlyk__Invoice__c.Name}"});
alert(result);
window.location.reload();
Thanks! I became angry like a buffalo trying to troubleshoot this... "O"
 

trigger CreateAssetonClosedWon on Opportunity (after insert, after update) {
     for(Opportunity o: trigger.new){ 
      if(o.isWon == true && o.HasOpportunityLineItem == true){
         String opptyId = o.Id;
         OpportunityLineItem[] OLI = [Select UnitPrice, Quantity, PricebookEntry.Product2Id, PricebookEntry.Product2.Name, Description, Converted_to_Assets__c  
                                      From OpportunityLineItem 
                                      where OpportunityId = :opptyId  and Converted_to_Assets__c = false];
         Asset[] ast = new Asset[]{};
         Asset a = new Asset();
         for(OpportunityLineItem ol: OLI){
            a = new Asset();
        a.AccountId = o.AccountId;
            a.Product2Id = ol.PricebookEntry.Product2Id;
            a.Quantity = ol.Quantity;
            a.Price =  ol.UnitPrice;
            a.PurchaseDate = o.CloseDate;
            a.Status = 'Purchased';
            a.Description = ol.Description;
            a.Name = ol.PricebookEntry.Product2.Name;
            ast.add(a);
            ol.Converted_to_Assets__c = true;
       }
      update OLI; 
      insert ast;
     }
    }

  • July 01, 2013
  • Like
  • 0

global class EmailTemplate implements Messaging.InboundEmailHandler {

global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
Messaging.InboundEnvelope envelope) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();

Products er = new Products__c();

String[] values = email.plainTextBody.split(',');
er.Contact__c = values[0];

String s = values[1];
Integer i = (Integer.valueof(s.trim()));
er.Amount__c = i;

String dt = values[2];
String[] stringDate = dt.split('/');
Integer m = Integer.valueOf(stringDate[0]);
Integer d = Integer.valueOf(stringDate[1]);
Integer y = Integer.valueOf(stringDate[2]);
Date product = date.newInstance(y,m,d);
er.Date__c = product;

er.Type__c = values[3];

er.Description__c = values[4];
er.Comments__c = values[5];

insert er;

return result;

 

Thanks in advance!