• Aditya Mohan
  • NEWBIE
  • 5 Points
  • Member since 2014
  • Salesforce Developer
  • Suyati Technologies


  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 12
    Replies
I am trying to access a list of Attachments related to a Contact from Custom Button during OnClick Javascript in a Javascript Array. But, the array doesn't display any value. It's blank.

Apex Class:
global class ZipAndSendAttachments {
webservice static List<AttachmentWrapper> getAttachments(String contactId)  {
    List<Attachment> lstAttachments = new List<Attachment>();
    lstAttachments = [SELECT Id, Name, ContentType, Body, ParentId
                      FROM Attachment
                      WHERE ParentId = :contactId];

    List<AttachmentWrapper> attWrapper = new List<AttachmentWrapper>();
    AttachmentWrapper a;
    for(Attachment att : lstAttachments){
        a = new AttachmentWrapper();
        a.attName = att.Name;
        a.attEncodedBody = EncodingUtil.base64Encode(att.Body);
        attWrapper.add(a);
    }

    System.debug('attWrapper '+attWrapper);
    return attWrapper;
}

global class AttachmentWrapper {
    public String attEncodedBody {get; set;}
    public String attName {get; set;}
}}

Javscript Button:
 
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
    {!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
    {!REQUIRESCRIPT("/resource/JSZip/Stuk-jszip-3a39a71/dist/jszip.min.js")} 

    var queryResult = [];
    var query = "SELECT Id, ParentId FROM Attachment WHERE ParentId = '{!Contact.Id}'"; 
    queryResult.push(sforce.connection.query(query)); 
    if(queryResult != null)
    {result = sforce.apex.execute("ZipAndSendAttachments","getAttachments",{contactId:"{!Contact.Id}"});
console.log('result::' + result);
    }

 
Hello, I am eagerly waiting for the rest of the modules to be updated. Any ideas when will the rest of the modules be updated like:
Apex Integration Services , Visualforce & JavaScript ..
 

How to display Salesforce data like a list of leads or any records on my Website page?

I guess we need to use REST API to do that rt..

Hello, I am eagerly waiting for the rest of the modules to be updated. Any ideas when will the rest of the modules be updated like:
Apex Integration Services , Visualforce & JavaScript ..
 
Hi, 
I am new to tirggers so I hope you can help, I need to send multiple email alerts based on a date field. 
The emails should send at 60,50,40,30 and 10 days before the Registration renewal date field. 
I can not use a workflow or process builder as the records will not be edited and the date may not be populated when the record is created.

I would be grateful if you could please advise as I am tottaly lost.

I hope this makes sense and Thank you in advance. 

Lorr
  • April 24, 2019
  • Like
  • 0
Hi All,
           Today I got "First Error: Apex CPU Limit Exceeded" error while executing batch apex.

            Not even a single batch got completed, below is the status of Apex Job.
            As it has failed in the first step itself, should we consider the failure is at START method ?       
Job Type	  Status	        Status Detail	                   Total Batches	Batches Processed	Failures	
 ----------   -------   -----------------------------------------  --------------   -----------------   --------
 Batch Apex	  Failed	First error: Apex CPU time limit exceeded       0	              1	                1

Thanks
 
I am trying to access a list of Attachments related to a Contact from Custom Button during OnClick Javascript in a Javascript Array. But, the array doesn't display any value. It's blank.

Apex Class:
global class ZipAndSendAttachments {
webservice static List<AttachmentWrapper> getAttachments(String contactId)  {
    List<Attachment> lstAttachments = new List<Attachment>();
    lstAttachments = [SELECT Id, Name, ContentType, Body, ParentId
                      FROM Attachment
                      WHERE ParentId = :contactId];

    List<AttachmentWrapper> attWrapper = new List<AttachmentWrapper>();
    AttachmentWrapper a;
    for(Attachment att : lstAttachments){
        a = new AttachmentWrapper();
        a.attName = att.Name;
        a.attEncodedBody = EncodingUtil.base64Encode(att.Body);
        attWrapper.add(a);
    }

    System.debug('attWrapper '+attWrapper);
    return attWrapper;
}

global class AttachmentWrapper {
    public String attEncodedBody {get; set;}
    public String attName {get; set;}
}}

Javscript Button:
 
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
    {!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
    {!REQUIRESCRIPT("/resource/JSZip/Stuk-jszip-3a39a71/dist/jszip.min.js")} 

    var queryResult = [];
    var query = "SELECT Id, ParentId FROM Attachment WHERE ParentId = '{!Contact.Id}'"; 
    queryResult.push(sforce.connection.query(query)); 
    if(queryResult != null)
    {result = sforce.apex.execute("ZipAndSendAttachments","getAttachments",{contactId:"{!Contact.Id}"});
console.log('result::' + result);
    }

 
we are using Java Webservices. I am using trail version in salesforce login credential. Initially i have accessed all the accounts and contacts later that i have changed my security token. After that i cant able to access accounts and contacts from salesforce. Exception occurs : "error[UnexpectedErrorFault [ApiFault  exceptionCode='API_DISABLED_FOR_ORG'
 exceptionMessage='API is not enabled for this Organization or Partner' "

How can i solve this issue??
Hi Everyone!

I have recently made a custom object called 'Prospects'. In my company prospects are seen as unqualified leads. Would anyone be able to help me create a convert button on my Prospect custom object which would convert the prospect into a Lead. The 'Lead' object I am referring to is the standard Salesforce Lead object. I have very little knowledge of Apex and Visual Force so any pointers would be much appreciated.

Thanks
Hi all,
I'm new for salesforce. I want to save data into database.
How to add record, answer me please.
this is code one in visualforce page.
<apex:pageBlock title="Other">
            <apex:commandButton value="addRow" action="{!addRow}"/>
            <br/><br/>
            <table class="table table-bordered" cellspacing="0" cellpadding="0" style="width:300px;">
                <tr>
                    <td style="background-color: #87CEEB;" align="center"><b>Other Name</b></td>
                    <td style="background-color: #87CEEB;" align="center"><b>Other Number</b></td>
                </tr>
                <apex:repeat value="{!row}" var="item" >
                    <tr>
                        <td align="center"><apex:inputText value="{!otherName}" id="otherName" html-placeholder="Other Name"/></td>
                        <td align="center"><apex:inputText value="{!otherNum}" id="otherNumber" html-placeholder="Other Number"/></td>
                    </tr>
                </apex:repeat>
            </table>
        </apex:pageBlock>

This is code one in controller.
//-- Add Row --\\
    public void addRow(){
        integer num = 1;
        String s = '';
        if(row == null){
            row = new List<String>();
            for(integer i = 0 ; i < num ; i++){
                s += num+'';
                row.add(s);
            }
            num++;
        }else{
            for(integer i = 0 ; i < num ; i++){
                s += num+'';
                row.add(s);
            }
            num++;
        }
    }
    //-- Add Row --\\

This is code two in visualforce page.
<apex:pageBlock title="Other">
            <apex:commandButton value="addRow" action="{!addRow}"/>
            <br/><br/>
            <table class="table table-bordered" cellspacing="0" cellpadding="0" style="width:300px;">
                <tr>
                    <td style="background-color: #87CEEB;" align="center"><b>Other Name</b></td>
                    <td style="background-color: #87CEEB;" align="center"><b>Other Number</b></td>
                </tr>
                <apex:repeat value="{!addOtherProduct}" var="item" >
                    <tr>
                        <td align="center"><apex:inputText value="{!item.Other_Name__c}" id="otherName" html-placeholder="Other Name"/></td>
                        <td align="center"><apex:inputText value="{!item.Other_Number__c}" id="otherNumber" html-placeholder="Other Number"/></td>
                    </tr>
                </apex:repeat>
            </table>
        </apex:pageBlock>

//-- Add Row --\\
    public void addRow(){
        addOtherProduct.add(new Product_Service__c(Other_Name__c = otherName, Other_Number__c = otherNum));
    }
//-- Add Row --\\

how to insert to database answer for me please.

Ther are 4 objects.
Route__c is a master
Route_outlet__c is Junction object for Route__c & Account.

And For Route__c there is one lookup for City__c

 

So My Requirment is,,,, While saving the Rout_outlet__c Record.
We must check the Account__r.BillingCity & route__r.City__r.name
if these two matches the rout_outlet__c record must save.

my Trigger is this

trigger AvoidCityNomatch on Route_Outlet__c (Before Insert, Before Update) {
for(Route_Outlet__c ro:Trigger.new){
if(ro.route__r.City__c!=ro.Account__r.BillingCity)
Ro.City__c.adderror('Account City & Rout City No Match');
}
}
in debug log ro.route__r.City__c showing null, pls guide me

i want to show a pop up message after clicking custom button in detail page

i has created a visualforce page and apex class and create a custom button for that VF page.its working properly when i click custom button
like /apex/vfpagename?id={}....

now i want to display one confirmation popup message after clicking custom button


 
Hi all, 

I'm trying to repeat bunch of rows in a pageblocktable. However I don't want my header to repeat, just the values. Right now, my headers doesn't show up at all!

How do I resolve this? 
 
<apex:outputPanel id="table">
            <apex:pageBlockTable value="{!LineItems}" var="item" columns="3">  

            <apex:repeat value="{!item}" var="m">              
                <apex:column ><apex:facet name="header">Materials</apex:facet>
                    <apex:inputfield value="{!m.Description__c}"/>
                </apex:column>     
                <apex:column ><apex:facet name="header">Ship</apex:facet>
                    <apex:inputfield value="{!m.Quantity_Shipped__c}"/>
                </apex:column>
            </apex:repeat>
            </apex:pageBlockTable>
</apex:outputPanel>


 
i don't knw how to write a record to custom object after querying the data from another objects.Plz help me
The feilds in custom obj(Article_Feedback__c) are Article_ID__c,Article_Title__c,Article_Type__c,Comments__c,Data_Category__c,Data_Category_Group__c and Reason__c.

My VFP:
<apex:page standardController="Core_Benefit__kav" extensions="GetURLnew"  >

            <apex:form>
                    <apex:outputField id="id" value="{!cbk.Id}"/>
                    <apex:outputField id="title" value="{!cbk.Title}"/>
                    <apex:outputField id="arttype" value="{!cbk.ArticleType}"/>
                    <apex:outputField id="artnumb" value="{!cbk.ArticleNumber}"/>
                    <apex:outputField id="urlname" value="{!cbk.UrlName}"/>
                    <apex:outputField id="createdby" value="{!cbk.CreatedById}"/>
                    <apex:outputField id="ownerid" value="{!cbk.OwnerId}"/>
                    <apex:inputField id="comments" value="{!cbk.Comments__c}"/>
                    <apex:inputField id="reason" value="{!cbk.Reason__c}"/>
                    <apex:outputText id="datacatname" value="{!Category.DataCategoryName}"/>
                    <apex:outputText id="datacatgrpname" value="{!Category.DataCategoryGroupName}"/>
                    <apex:commandButton action="{!save}" value="save"/>         
              </apex:form> 

</apex:page>

My controller:

public class GetURLnew {
    public List<Article_Feedback__c> artfeed=new List<Article_Feedback__c>();
    public Core_Benefit__kav filterid;
    public string cbkId {get; set;}
    public Core_Benefit__DataCategorySelection CatDetails;
    public Core_Benefit__kav cbk {get; set;}
  
    public GetURLnew(ApexPages.KnowledgeArticleVersionStandardController controller) {
        cbkId = apexpages.currentpage(). getParameters().get('id');
        cbk = new Core_Benefit__kav();
        if(cbkId != null && cbkId != '') {
            cbk = [Select Id, Title,Exam__c,Lens__c,UrlName, Lens_Enhancements__c,Frame__c,Contacts__c,Support_Queue_Steps__c,Doctor_Network__c,Lab__c,Additional_Benefits__c, ArticleType, ArticleNumber, CreatedById, OwnerId, Comments__c, Reason__c from Core_Benefit__kav where PublishStatus = 'online' AND Language = 'en_US' AND KnowledgeArticleId =: cbkId];
        }
       
    }
   
    public Core_Benefit__DataCategorySelection getCategory() {
        return CatDetails;
    }
    public PageReference save() {
        
         filterid=[SELECT Id,UrlName FROM Core_Benefit__kav WHERE ArticleNumber =: cbk.ArticleNumber AND PublishStatus = 'online' AND Language = 'en_US'];        
         CatDetails= [Select DataCategoryName,DataCategoryGroupName from Core_Benefit__DataCategorySelection where ParentId =:filterid.Id];
         
        insert artfeed;
        
    }  
}