• Sergio Mac-Intosh
  • NEWBIE
  • 25 Points
  • Member since 2015

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 3
    Replies
I have 2 classes containing various methods.

In the first class I want to call the class "addInvoice()"

The addInvoice class should return the invoiceID

I would like to take the returned invoiceID and assign it to a variable to be used elsewhere in the class

Here is the call in the first class:
 
InvoiceAdd invoice = new InvoiceAdd();
           String invID = invoice.invID;

This is the method in the second class
Public String InvoiceAdd(String projID, String oppID) {
    system.debug('1');
    Invoice__c inv = new Invoice__c(Project__c = projid);
       system.debug('2');
        insert inv;
        String invID = inv.id;
        system.debug('3');
        system.debug('oppID ' + oppID);
        system.debug('invID ' + invID);
 return invID;
}
 
I just keep getting errors such as:  Error: Compile Error: Invalid type: InvoiceAdd at line 65 column 38

Any help?
 
  • August 03, 2015
  • Like
  • 0
Hi,

My google maps integration on a visualforce page isn't working for Salesforce portal users.
The functionality works for Salesforce full license users. I added the library to the page:

<apex:includeScript value="//maps.google.com/maps/api/js?sensor=false&libraries=geometry"/>

Portal users can't reach this library but Salesforce full users can.

How can i make this library reachable for portal users?
Hi People,

I got a function which creates an attachment on a visualforce page. The functionality is working when i call the button from a apex button.
Now i overwrite the chatter save button to get the functionality on this button. When i use this button i get the error:
An error has occurred {faultcode:'UNKNOWN_EXCEPTION', faultstring:'UNKNOWN_EXCEPTION: Site under construction', }

The javascript code of the function is:
<script> 
    Sfdc.canvas.publisher.subscribe({name: "publisher.showPanel",
        onData:function(e) {
            Sfdc.canvas.publisher.publish({name:"publisher.setValidForSubmit", payload:"true"});
    }});
    Sfdc.canvas.publisher.subscribe({ name: "publisher.post",
        onData:function(e) {
            uploadFile();
    }}); 
</script>
	    <script>

        
    function uploadFile()
	{       
    $('#working').toggle();
    sforce.connection.sessionId = "{!$Api.Session_ID}";
    
    var cost = document.getElementById('costs').value;
    var details = document.getElementById('details').value;
    var input = document.getElementById('file-input');
    var parentId = 'a5ZL00000000CF7';


    var filesToUpload = input.files;
    
    if(filesToUpload.length == 0){
        alertify.error('No Attachment Found')
        $('#working').toggle();
    }

    for(var i = 0, f; f = filesToUpload[i]; i++)
    {
        var reader = new FileReader();     

        // Keep a reference to the File in the FileReader so it can be accessed in callbacks
        reader.file = f; 

        reader.onerror = function(e) 
        {
            switch(e.target.error.code) 
            {
                case e.target.error.NOT_FOUND_ERR:
                    alertify.error('File Not Found!')
                    $('#working').toggle();
                    break;
                case e.target.error.NOT_READABLE_ERR:
                    alertify.error('File is not readable')
                    $('#working').toggle();
                    break;
                case e.target.error.ABORT_ERR:
                    break; // noop
                default:
                    alertify.error('An error occurred reading this file.')
                    $('#working').toggle();
            };
        };     

        reader.onabort = function(e) 
        {
            alertify.error('File read cancelled')
            $('#working').toggle();
            
        };

        reader.onload = function(e) 
        {
            var att = new sforce.SObject("Attachment");
            att.Name = this.file.name;
            att.ContentType = this.file.type;
            att.ParentId = parentId;
            att.Description = 'Prijs:' + cost + '-Omschrijving:' + details;

            att.Body = (new sforce.Base64Binary(e.target.result)).toString();

            sforce.connection.create([att],
            {
                onSuccess : function(result, source) 
                {
                    if (result[0].getBoolean("success")) 
                    {
                        console.log("new attachment created with id " + result[0].id);
                        alertify.success('Nieuwe onkosten zijn toegevoegd')
           				setTimeout(closeAction, 3000);
                    } 
                    else 
                    {
                        console.log("failed to create attachment " + result[0]);
                    }
                }, 
                onFailure : function(error, source) 
                {
                    alertify.error("An error has occurred " + error)
                    console.log(error);
           			$('#working').toggle();
                }
            });
        };

        reader.readAsBinaryString(f);
    }
}
    function closeAction()
    {
        Sfdc.canvas.publisher.publish({name: "publisher.close", payload:{ feed:"true", refresh:"true"}});
    } 
</script>

Anyone got any idea?
 
How can i get the distance between two locations (Accounts)?
I would like to use the google maps integration to get the distance to get from a too b.
How can my testclass test service calls.
When i run the testclass atm it stopt because of Salesforce doesn't support these calls.
Scrolling doesnt work on ios for my visualforce pag chatter action.
Any idea how i can solve this problem?
 
Hi,
I got some functionality which uploads files from a visualforce page.
The problem is that mobile pictures are always to big. Because of this Salesforce won't accept the base64 because the size is to big.
How can i resize this before uploading. For small images the functionality works perfect.
Code atm:

Javascript:
function uploadFile()
{       
    var input = document.getElementById('file-input');
    var parentId = 'a0fL0000004TCDA';

    var filesToUpload = input.files;

    for(var i = 0, f; f = filesToUpload[i]; i++)
    {
        var reader = new FileReader();     

        // Keep a reference to the File in the FileReader so it can be accessed in callbacks
        reader.file = f; 

        reader.onerror = function(e) 
        {
            switch(e.target.error.code) 
            {
                case e.target.error.NOT_FOUND_ERR:
                    alert('File Not Found!');
                    break;
                case e.target.error.NOT_READABLE_ERR:
                    alert('File is not readable');
                    break;
                case e.target.error.ABORT_ERR:
                    break; // noop
                default:
                    alert('An error occurred reading this file.');
            };
        };     

        reader.onabort = function(e) 
        {
            alert('File read cancelled');
        };

        reader.onload = function(e) 
        {
            var att = new sforce.SObject("Attachment");
            att.Name = this.file.name;
            att.ContentType = this.file.type;
            att.ParentId = parentId;

            att.Body = (new sforce.Base64Binary(e.target.result)).toString();
            var testvar = att.Body;
            alert('Test:' + testvar.length );

            sforce.connection.create([att],
            {
                onSuccess : function(result, source) 
                {
                    if (result[0].getBoolean("success")) 
                    {
                        console.log("new attachment created with id " + result[0].id);
                    } 
                    else 
                    {
                        console.log("failed to create attachment " + result[0]);
                    }
                }, 
                onFailure : function(error, source) 
                {
                    console.log("An error has occurred " + error);
                }
            });
        };

        reader.readAsBinaryString(f);
    }
}
HTML:
<input id="file-input" type="file" name="file"/>
<input type="button" value="Add Review" style="font-size:12px;"  onclick="uploadFile;"/>

Thanks in Advance!

 
How can i remove the header of a chatter action(Vf page)? Removing the save button would be a good workaround too! This button isn't used on the page i'm showing.
 User-added image
Hi,

I am having a apex class which i am trying to post the opp id and account id from opportunity along with the text on opportunity object alone , this fires on posting a content i n chatter


i have written the apex class , but for some reasong its not firing

help me if i am doing anything wrong here
 
public class EditFeedItemHelper {

  /**

  * Call this method from an after insert FeedItem trigger.

  * It updates the feed items passed in and preserves @mentions.

*/

  public static void edit(FeedItem[] feedItems) {

    String communityId = Network.getNetworkId();

    List<String> feedItemIds = new List<String>();

    for (FeedItem f : feedItems) {

        feedItemIds.add(f.id);

    }

        // Get all feed items passed into the trigger (Step #1).

    ConnectApi.BatchResult[] results = ConnectApi.ChatterFeeds.getFeedElementBatch(communityId, feedItemIds);

    for (ConnectApi.BatchResult result : results) {

        if (result.isSuccess()) {

            Object theResult = result.getResult();

            if (theResult instanceof ConnectApi.FeedItem) {

                ConnectApi.FeedItem item = (ConnectApi.FeedItem) theResult;

                // Convert message segments into input segments (Step #2a).

                ConnectApi.FeedItemInput input = ConnectApiHelper.createFeedItemInputFromBody(item.body);

                // Modify the input segments as you see fit (Step #2b).

                modifyInput(input);

                // Update the feed item (Step #2c).

                // We need to update one feed item at a time because there isn't a batch update method yet.

                ConnectApi.ChatterFeeds.updateFeedElement(communityId, item.id, input);

            }

            else {

                // Do nothing. Posting other feed element types isn't supported.

            }

        }

        else {

                System.debug('Failure in batch feed element retrieval: ' + result.getErrorMessage());

        }

    }

}

    /**

    * Update the feed item input here!

    */

    public static void modifyInput(ConnectApi.FeedItemInput input) {

          set<id> parentAccountIds = new set<id>();
          List<FeedItem> fd = new List<FeedItem>();
              for(FeedItem fdItem : fd){
          String idStr = fdItem.Parentid;
            if(idStr.startsWith('006')){
           parentAccountIds.add(idStr);
        }
                      }
        
           Map<id,Opportunity> oppty  = new Map<id,Opportunity>([Select id, AccountId  from Opportunity where id in:parentAccountIds]);
             if(oppty.size()>0){
             for(FeedItem fdItem : fd){
          Opportunity parentopportunity = oppty.get(fdItem.Parentid);
                  String chatterBody = fdItem.Body;
           fdItem.Body = chatterBody + '\n Account Id is :'+ parentopportunity.AccountId + ' \n Opportunity Id :'+parentopportunity.Id;


            
             
              



        // This example appends text to the feed item.

        ConnectApi.TextSegmentInput textInput = new ConnectApi.TextSegmentInput();

        textInput.text =  chatterBody ;


        input.body.messageSegments.add(textInput);

    }
      }
              
     }

}


Kindly help me

Thanks
 
I have 2 classes containing various methods.

In the first class I want to call the class "addInvoice()"

The addInvoice class should return the invoiceID

I would like to take the returned invoiceID and assign it to a variable to be used elsewhere in the class

Here is the call in the first class:
 
InvoiceAdd invoice = new InvoiceAdd();
           String invID = invoice.invID;

This is the method in the second class
Public String InvoiceAdd(String projID, String oppID) {
    system.debug('1');
    Invoice__c inv = new Invoice__c(Project__c = projid);
       system.debug('2');
        insert inv;
        String invID = inv.id;
        system.debug('3');
        system.debug('oppID ' + oppID);
        system.debug('invID ' + invID);
 return invID;
}
 
I just keep getting errors such as:  Error: Compile Error: Invalid type: InvoiceAdd at line 65 column 38

Any help?
 
  • August 03, 2015
  • Like
  • 0
How can i get the distance between two locations (Accounts)?
I would like to use the google maps integration to get the distance to get from a too b.