• NK@BIT
  • NEWBIE
  • 115 Points
  • Member since 2014
  • Bit Order Technologies

  • Chatter
    Feed
  • 3
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 47
    Replies
Hi,

I want to collect all the values for a particular field from a multiple lookup records and add it to a field in parent record. Individual values should be comma separated. How should I acieve this through trigger? Thanks in advance!
Hi all, I want to preface this by saying I have absolutley zero knowledge of coding and how to write an apex trigger. However, I do know the result i'm trying to achieve so I'm hoping my description will be enough for someone to provide some help.

My situation is the following: I have 2 custom objects Volunteer and Subject. What I want to happen is that when a certain field (Volunteer_Status__c), a picklist value, is updated to the selection "Screening Completed" a new record is created under the Subject object that replicates the information stored under the volunteer record.

If someone could provide some instruction it would be much appreciated!
trigger createSplitCommissionOnOpportunityX on Opportunity (after insert, after update) {
   
    List<Split_Commissions__c> SCToInsert = new List<Split_Commissions__c>  ();
  
    for (Opportunity o : Trigger.new) {
       
      
    if ( ((Trigger.isInsert) ||
          (Trigger.isUpdate) && (Trigger.oldMap.get(o.id).StageName !=  'Closed Won')) &&
         (o.StageName == 'Closed Won') )
    {
        Split_Commissions__c SC = new Split_Commissions__c ();        
       
        sc.Opportunity_Name__c = o.id;
       
        SCToInsert.add(sc);
       
       
        }//end if
       
    }//end for o
   
    //once loop is done, you need to insert new records in SF
    // dml operations might cause an error, so you need to catch it with try/catch block.
    try {
        insert SCToInsert;
    } catch (system.Dmlexception e) {
        system.debug (e);
    }
}

PLease help us to create the test class for the above code.


Thanks,
While installing a managed package in one of my customer org in which Advanced Currency Management enabled I am getting thid error. Can any one tell me why this error is coming?
  • October 08, 2014
  • Like
  • 0
I am getting this error when trying to open one of my email template for preview. Can any one tell me why this error is coming and how I can debug this error?
  • September 23, 2014
  • Like
  • 0
I have a visualforce page in which I reterieve record after search in a pageblock table. I have a button which exports a CSV file for those records. For those CSV records I have written a visualforce page whose content type I have set to CSV. After export CSV file I want to reload the page.
Please help me in writing test class for this controller..

public with sharing class TimeCardController{

    public Timecard__c timecard1{get; set;}
    public List<Resource__c> resource{get; set;}
    public String passcode{get; set;}
    public Boolean Match{get; set;}
    public Boolean NoMatch{get; set;}
    public Boolean readValue1{get;set;} 
    public String resourceName{get;set;} 
  
    Public TimeCardController(){
        timecard1 = new Timecard__c();
        readValue1 =true;
    }
  
   Public void timecardsignin(){
       resource=new List<Resource__c>();
       Match=false;
       NoMatch=false;
       readValue1 =false;
      
       resource=[select Id, Name, Passcode__c from Resource__c where Id=:timecard1.Resource__c AND Passcode__c=:passcode];
      
       if(resource.size()>0)
       {
           Match=true;
       }
       else
       {
           NoMatch=true;
       }
   }
  
    public PageReference timeCard(){
        Timecard__c tc=new Timecard__c();
        tc.Resource__c=timecard1.Resource__c;
        tc.Project__c=timecard1.Project__c;
        tc.Activity_Date__c=timecard1.Activity_Date__c;
        tc.Project_Task__c=timecard1.Project_Task__c;
        tc.Activity_Description__c=timecard1.Activity_Description__c;
        tc.Hours__c=timecard1.Hours__c;
      
        insert tc;
        resourceName=resource[0].name;
        readValue1 = true;
        Match=false;
       
        apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.Info,'Time Card Successfully Updated for '+ resourceName);
        apexpages.addmessage(msg);
        timecard1.clear();
        return null;
       
    }  
    public PageReference doCancel()
    {
        PageReference pageRef = new PageReference('http://crmdev-bitorder.cs6.force.com/timecard');
        pageRef.setRedirect(true);
        return pageRef;
    }

  }
  • January 27, 2014
  • Like
  • 0
I want to write test class for this Email Service apex class

global class ResourceToLeave implements Messaging.InboundEmailHandler {

  global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email,
                                                       Messaging.InboundEnvelope env){

    // Create an InboundEmailResult object for returning the result of the
    // Apex Email Service
    Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
   
    String[] emailBody = email.plainTextBody.split('\n', 0);
   
    String startdate = emailBody[0].substring(10);
    String[] tempStr = startdate.split('/');
    Integer d = Integer.valueOf(tempStr[0]);
    Integer m = Integer.valueOf(tempStr[1]);
    Integer y = Integer.valueOf(tempStr[2]);
    Date sdt = Date.newInstance(y,m,d);
   
    String enddate = emailBody[1].substring(8);
    String[] tempStr1 = enddate.split('/');
    Integer dd = Integer.valueOf(tempStr1[0]);
    Integer mm = Integer.valueOf(tempStr1[1]);
    Integer yy = Integer.valueOf(tempStr1[2]);
    Date edt = Date.newInstance(yy,mm,dd);
      
    // New Leave object to be created
    Leave__c[] leave = new Leave__c[0];
  
    // Try to look up any contacts based on the email from address
    // If there is more than one contact with the same email address,
    // an exception will be thrown and the catch statement will be called.
    try {
      Resource__c[] resource = [SELECT Id, Name FROM Resource__c WHERE Name = :email.subject LIMIT 1];
     
      Resource__c res;
      if(resource.size()>0)
      {
          res=resource[0];
      }
      // Add a new Task to the contact record we just found above.
      leave.add(new Leave__c(Resource__c=res.Id,
                             Start_Date__c=sdt,
                             End_Date__c=edt
                             ));
    
     // Insert the new Leave
     insert leave;   
    
     System.debug('New Leave Object: ' + leave );  
    }
    // If an exception occurs when the query accesses
    // the contact record, a QueryException is called.
    // The exception is written to the Apex debug log.
   catch (System.QueryException e) {
       System.debug('Query Issue: ' + e);
   }
  
   // Set the result to true. No need to send an email back to the user
   // with an error message
   result.success = true;
  
   // Return the result for the Apex Email Service
   return result;
  }
}
  • January 08, 2014
  • Like
  • 0
I have an object "Leave"

I want that if i send a mail using "Email Service Address" and in Email body i sends StartDate and EndDate Value,

Than StartDate and EndDate Values insert into the Start_Date__c and End_Date__c field of "Leave" Object.

So please tell me how to do this.
  • January 08, 2014
  • Like
  • 0
I have an obejct "Leave".

I want that if i sends a mail by putting "Email to Salesforce address" in BCC than it should go in task of "Leave" record without going in "Unresolved items".

So please tell me is this possible or not?
  • January 07, 2014
  • Like
  • 0
I have a visualforce page in which I reterieve record after search in a pageblock table. I have a button which exports a CSV file for those records. For those CSV records I have written a visualforce page whose content type I have set to CSV. After export CSV file I want to reload the page.
Hi All,

I have a component with lightning-record-edit-form which has lightning-input-field . The field is of data type "PicklList" and it has a onchange event. I am displaying the save and cancel button on change of picklist.

 On click of cancel I am resetting the picklist fields using field.reset() and setting the boolean variable(which is used to hide button) to False.

However, On click of cancel field reset is triggering the onchange event and making the boolean variable(which is used to hide button)to true and displaying the buttons.

I found a link in which salesforce provided a solution to a similar issue in Aura.
https://help.salesforce.com/articleView?id=000352380&language=en_US&mode=1&type=1 

Could you please help me with this issue in LWC?
I'm trying to create my first custom LWC for my own org. I want to just put a smiley face image in the middle of the component with some text at the top. Here is the code below:

js:
import { LightningElement } from 'lwc';
export default class SmileyFinal extends LightningElement 
{
    pictureUrl = 'https://en.wikipedia.org/wiki/Smiley#/media/File:SNice.svg'; 
}

html:
<template>
    <body> 
        <div class="slds-m-around_medium">
            <h1 class="slds-text-heading_small">Welcome to Brendan's Smiley Class</h1>
            <p>The first of many projects.</p>
        </div>
        <div class="slds-container_center">
                <img src={pictureUrl}>
        </div>
    </body>
</template>

css:
body{    
    font-family: Helvetica; 
    color: black; 
    text-align: center;
    justify-content: center;
    margin: 0; 
}
Hi,
Thank you for reading my question first. I am facing difficulty in connecting to Azure Blob from Salesforce APEX class.
I am following this example from and following link for reference
 https://github.com/nagensahu/AzureBlobStorage-Salesforce/blob/master/Readme.md
This is in the end my header looks like
x-ms-date: Wed, 11 Mar 2020 00:36:39 GMT
x-ms-version : 2015-12-11 Content-Length : 213980
Authorization: SharedKey zaindevtesting:6SfwH21pfpr9NiiK8PXXL9IMOs9SWNEvl3Elj2Jfc3w%3D
Content-Type:application/pdf
Request Type PUT 
https://zaindevtesting.blob.core.windows.net/zaindevblob/Consent+form+%281%29.pdf
I have tried using postman but getting same. You can use same Link to access my test Azure from postman and let me know if some information is required.
I am trying to upload file from sales force but getting following error.
 
<?xml version="1.0" encoding="utf-8"?>
<Error>
    <Code>InvalidAuthenticationInfo</Code>
    <Message>Authentication information is not given in the correct format. Check the value of Authorization header.
RequestId:6b4f54fd-501e-0013-5f9e-f6c88c000000
Time:2020-03-10T05:43:44.8911977Z</Message>
</Error>

 
Hi All,

I am new to developing and give me some insights how to upload csv file using LWC .

Regard,
Siva 
Hi guys,
I'm trying to wire a function as described here (https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.data_wire_service_about).

This is my code:
 
@wire(getRecord, { recordId: '$recordId', fields: ['Lead.Name'] })
    wiredRecord({ error, data}){
        if (data) {
            this.record = data;
            this.error = undefined;
        } else if (error) {
            this.error = error;
            this.data = undefined;
        }
        console.log('test '+JSON.stringify(this.record));
    };

get test() { 
    return this.record.fields.Name.value; 
}
Everything works fine and I got the following log of the data:
{"apiName":"Lead","childRelationships":{},"fields":{"Name":{"displayValue":null,"value":"Test Name"}},"id":"00Q0D000001njilUAA","lastModifiedById":"005240000052XZeAAM","lastModifiedDate":"2019-03-21T13:41:40.000Z","recordTypeInfo":{"available":true,"defaultRecordTypeMapping":true,"master":false,"name":"Customer","recordTypeId":"01224000000SVMWAA4"},"systemModstamp":"2019-03-21T13:41:40.000Z"}
If I want to access the value like it described in the link (e.g. this.record.fields.Name.value;) with this.record.fields.Name.value; I get the error:

Cannot read property 'fields' of undefined

What is wrong and why can't I access the fields/value?

 
Hi All,

  I have requirement to upload CSV file into Salesforce using lightning component then this record will insert in Sobject records.Please guide me on this scenario.

Thanks,
Santhanam
what is the best option to extend the storage from SFDC to cloud service say Azure or S3 securely and access as an URL
Hi Team,
I am creating ContactSearchBar and ContactList as single component. On initialization of component am loading all the contacts to list after  in serach bar if i type any charachter am getting "Cannot read property 'value' of undefined"  error.Please find my snippet code
({
	doInit : function(component, event, helper) {
		  var action = component.get("c.findAllContactsList");
          action.setCallback(this, function(a) {
            component.set("v.Accounts", a.getReturnValue());
        });
        $A.enqueueAction(action);
	},
    ContactNameSearchKeyChange: function(component, event, helper) {
        var myEvent = $A.get("e.c:ContactSearchKeyEvent");
         
        myEvent.setParams({"searchKey": event.target.value});
        myEvent.fire();
          
    },
  
    ContactNameSearchKeyChange: function(component, event) {
    var searchKey = event.getParam("searchKey");
    var action = component.get("c.findByContactName");
    action.setParams({
      "searchKey": searchKey
    });
    action.setCallback(this, function(a) {
        component.set("v.contacts", a.getReturnValue());
    });
    $A.enqueueAction(action);
}
})

 
I am getting (403) Forbidden error  in outbound message. My endpoint url is RequestB.in. 


Outbound Message



WF Action

As a result I am not getting a y reponse at my endpoint url:

User-added image
Hi All,

Can anyone please help me with a code that freezes my header row when I export an excel file from the Visualforce page?. I am able to add autofilters though but I have not found a way to freeze headers. 

Thank you all in advance.
I have 2 outbound messages set as a system user with full admin rights to send as.  When I perform a test in the full sandbox the outbound message is sent.  When any user that is not a full admin creates and closes the case it doesn't fire the outbound message, but it does the other action that is part of the workflow which is a field update.  

Any ideas why it's not queuing and firing off the outbound message for non-admins, but successully performs the other actions in the same workflow?

Thank you.  

 
Hi All,

I am getting the below error's when i am trying to invoke 3rd party system via outbound message call.
Please help.

(403)Forbidden
java.io.IOException:Stream closed.

Thanks...
I have a visualforce page in that i have created two button
1) Export Excel
2)Export Pdf

I have written code for for bothexport page in excel and PDF using rerender and contettype.
Also i have added custom button on my visulforce page.
<apex:commandButton action="{!URLFOR($Action.Five_c.Generate, Id)}" id="pdf" value="pdf"/>
<apex:commandButton action="{!URLFOR($Action.Five_c.excel, Id)}" id="excel" value="excel"/>
Now the problem is once I click on pdf button it redirect to the pdf page .What my requirnment is that pdf should open in new window i.e child page and parent page should also visible to us.

Similary for Excel it should happen
HI All,

I have a Requirment Integration salesforce with Microsoft Azure Any Ideas appreciated.

Thanks,
Hareesh
I have a Developer Edition account as I am trying to do a POC on integration of SFDC using Tibco BW.
I have created a Workflow Rule which triggers an Outbound Message. The message will be recieved by a Tibco BW Web Service on tibco's end over HTTP.

Even though the URL in the outbound Message matches the Webservice URL, the outbound message get's stuck on the SFDC side with a Delivery Failure Reason '(403) Forbidden'.

Please tell me what is the reason for the error as there is no information that i could find on this. Also, how can i fix this.
  • January 04, 2014
  • Like
  • 0

Hi,

I want to implement the standard export and Printable view functionality of reports in a visualforce page.

Can anyone let me know if this is possible.

 

Thanks in advance.

Hi All,

 

Is there any endpoint URL available to test Workflow outbound message?

I want to know what information is going through outbound message, so i need an endpoint URL to test?

Kindly tell me, is there any website(end point url) to test.

 

I already used one endurl for testing, but unfortunately i forgot that url.

I got that url from the salesforce discussion board only.

I'm currently designing a new customer portal and was wondering if it's possible to allow the user to upload a Document.

It would be easier if the user just get an inputFile option and the file that he selects is mailed to another person. I've got the apex and visualforce code for that setup but the file contained in the email is 0KB and there's nothing in the file.

Here's a part of my visualforce code

<apex:outputPanel id="MigrateBlock">
<apex:pageBlock title="Migrate Block" rendered="{!RenderMigrateType}">
<apex:pageBlockButtons >
<apex:commandButton action="{!SaveMigrate}" value="Migrate License"/>
</apex:pageBlockButtons>
<apex:pageBlockSection showHeader="false" columns="2" id="block76">

<apex:pageBlockSectionItem >
          <apex:outputLabel value="File Name" for="fileName"/>
          <apex:inputText value="{!document.name}" id="fileName"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="File" for="file"/>
          <apex:inputFile value="{!document.body}" filename="{!document.name}" id="file"/>
        </apex:pageBlockSectionItem>

        <apex:pageBlockSectionItem >
          <apex:outputLabel value="New Host IP Address" for="adasds"/>
          <apex:inputText value="{!HostIpAddress}" id="adasds"/>
        </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
</apex:pageBlock>
</apex:outputPanel>



And here's the Apex Code

public Document document
   {
   get{
   if (document == null)
        document = new Document();
   return document;
   }
   set;
}

public PageReference SaveMigrate()
{
document.FolderId = UserInfo.getUserId();
       insert document;

      document.body = null;
       document = new Document();
  if(HostIPAddress != null)
  {
  ContractAsset__c n = [SELECT id, Contract__r.id FROM ContractAsset__c WHERE Asset__r.Product2Code__c =: selectedAssets.Product2Code__c AND Contract__r.ContractNumber = :contractNumber LIMIT 1];
  Asset a = [SELECT Id from Asset WHERE Product2Code__c =: selectedAssets.Product2Code__c LIMIT 1];
  LicenseKey__c newData = new LicenseKey__c(ContractAsset__c = n.id,
  Ip_Address__c = HostIpAddress,
  LicenseType__c = 'Migrate',
  asset__c = a.id,
  Contract__c = n.Contract__r.id);
  sendEmail(); // Sends the email with a setDocumentAttachment
  insert newData;
  }

return null;

}

It's all for the Customer Portal. Any ideas how to mail the file without uploading it onto salesforce before?

  • November 08, 2010
  • Like
  • 0

Hi Folks.....


I used the following Javascript to export my table of data to excel.

 

   <script type="text/javascript">

   function exportToExcel(){

       var oExcel = new ActiveXObject("Excel.Application");

       var oBook = oExcel.Workbooks.Add;

       var oSheet = oBook.Worksheets(1);

       for (var y=0;y<ExportTable.rows.length;y++){

           for (var x=0;x<ExportTable.rows(y).cells.length;x++){

               oSheet.Cells(y+1,x+1) =ExportTable.rows(y).cells(x).innerText;

           }

       }

       oExcel.Visible = true;

       oExcel.UserControl = true;

   }

   </script>


Through this code my requirement is almost reached except one issue.I developed a table using Visualforce in Salesforce.I've added the above javascript in the visualforce code.I was successful in exporting the data to Excel having the tags <apex:inputText> but not <apex:outputText>.

My sample code for
table is provided below for more information:

<table id="ExportTable">
<tr>
  <td width="10%" BGCOLOR="#99CCFF"><center><b>April</b></center> </td>

  <td> <apex:inputText value="{!April1}" disabled="{!Apr1a}"/> </td>
  <td> <apex:inputText value="{!April2}" disabled="{!Apr2a}"/></td>
  <td> <apex:inputText value="{!April3}" disabled="{!Apr3a}"/> </td>
  <td> <apex:outputText value="{0,number,0.00}" id="AprilTotal">  
      <apex:param value="{!AprilTotal}"/>
     </apex:outputText>     
   </td>     
  </tr>   
</table>

I was able to export the "AprilTotal" value in to Excel with the above javascript code but not the values in "April1","April2","April3".

Kindly suggest a solution on how to export the values in <apex:outputText> tags.

Thanks & Regards,
Jagadeesh K.

I have found multiple posts on how to edit the apex:page line so that when the VF page is activated, it saves itself to an excel file:

 

<apex:page cache="true" contentType="application/vnd.ms-excel#test.xls" controller="StoreController" language="english">

 

But what I need to do is display the VF page with the panelGrid.  Then the user can click a button or link that will export the grid to excel.

 

I was thinking of just creating a second visualforce page that contains the above apex:page line, but I don't know how to add that logic to a button/link.

 

Thanks

 

Todd