• Anupam
  • NEWBIE
  • 45 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 25
    Replies
I wrote a class 
public with sharing class SlackOpportunityPush {
    
    
    // To publish Opportunity values in form of a String//
    public static final String slackURL = 'https://hooks.slack.com/services/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';
    
    public class Oppty {
        @InvocableVariable(label='Opportunity Name')
        public String opptyName;
        
        @InvocableVariable(label='Owner')
        public String Owner;
        
        @InvocableVariable(label='Opportunity Amount')
        public String Amount;
        
        @InvocableVariable(label='Account Development Owner')
        public String AccountDE;
        
        @InvocableVariable(label='Account')
        public String Account;
    }
     
    @InvocableMethod(label='Push to Slack')
    
    public static void postToSlack(List<Oppty> oppties) { 
        Oppty o = oppties[0]; // If bulk, only post first to avoid overloading Slack channel
        Map<String,Object> msg = new Map<String,Object>();
        msg.put('text',  '\n Opportunity Won !  Congrats to Opportunity Owner !  :-  ' +o.Owner +   '\n and Account Development Owner:-  '+ o.AccountDE + '\n who just closed Opportunity:-  ' +o.opptyName +   '\n associated to Account:- ' + o.Account +'\n for Opportunity Amount:- $ ' + o.Amount);
        
        System.debug('Called msg.put');
        System.debug('OpportunityOwner '+o.Owner);
        System.debug('OpportunityAccount '+o.Account);
        System.debug('OpportunityAmount '+o.Amount);
        
        
        msg.put('mrkdwn',true);
        String body = JSON.serialize(msg);    
        System.enqueueJob(new QueueableSlackCall(slackURL,'POST',body));
    
    
    
    }
     
    public class QueueableSlackCall implements System.Queueable, Database.AllowsCallouts {
         
        public final String url;
        public final String method;
        public final String body;
         
        public QueueableSlackCall(String url,String method,String body) {
            this.url = url;
            this.method = method;
            this.body = body;
        }
         
        public void execute(System.QueueableContext ctx) {
            HttpRequest req = new HttpRequest();
            req.setEndpoint(url);
            req.setMethod(method);
            req.setBody(body);
            Http http = new Http();
            HttpResponse res = http.send(req);
        }
 
    }
    
}
Test class 
@isTest
private class SlackOpportunityTest {
    

static testMethod void testpostToSlack() {
SlackOpportunityPush.Oppty opt = new SlackOpportunityPush.Oppty();
opt.opptyName = 'Unit Test Opt';
opt.Owner = 'Unit Test Owner';


List<SlackOpportunityPush.oppty> lis = new List<SlackOpportunityPush.oppty>();
lis.add(opt);
SlackOpportunityPush.postToSlack(lis);

System.assertEquals(lis, lis); 
    
}
     
}

Code coverage is now 100% but while deploying the classes I get error:

​Methods defined as TestMethod do not support Web service callouts 
Stack Trace: null
Hi 

I am following the lighting web component trailhead (https://trailhead.salesforce.com/content/learn/projects/quick-start-lightning-web-components/create-a-hello-world-lightning-web-component ).
I created the web component, but when i try to add it to the home component, the custom web component is not showing and cannot add it to the home page. The helloworld.js-meta.xml file is same as what metioned in the trailhead account.
I am doing this in my trailhead playground. Any help on this will be highly appreciated
  • March 11, 2019
  • Like
  • 0
Hi

I just activated namespace prefix in my developer account, and after that i am not able to access my project in eclipse or mavensmate force.com IDE. I also tried creating new project and was not successfull. I am getting read time out error while fetching the metadata in eclipse. 
I am able to login successfully through browser. 
See the error message belowUser-added image
  • March 11, 2016
  • Like
  • 0
Hi 
  • I converted the metadata wsdl to apex class through wsdl to apex button and it created a class soapSforceCom200604Metadata in the system. But when i try to open it it gives me below error.
  • An internal server error has occurred
    An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. 

    Thank you again for your patience and assistance. And thanks for using salesforce.com! 
  •  
  • Thanks
  • Anupam

    Error ID: 1281456891-49957 (-1437854107)
  • January 14, 2015
  • Like
  • 1

Hi

 

I am trying to access my Rest API class from curl but i am not able to connect my instance using curl.

 

1. First of all if i want to call my WS through curl what will be the callback url in the remote access setting?

2. When ever i try to call the REST WS through curl using the curl command "curl -H "Authorization: Bearer Access Token "https://ap1.salesforce.com/services/apexrest/Fiserv/GetService/Account ID" " i am getting an SSL error.If i replace it -H with -k it throws invalid session ID.

 

Please help me on this.

 

Hi

 

Can somebody make me understand the use of trigger Implicit variable isExecuting with example?

 

Thanks in Advance!!

 

Anupam

  • November 03, 2011
  • Like
  • 0
Hi 
  • I converted the metadata wsdl to apex class through wsdl to apex button and it created a class soapSforceCom200604Metadata in the system. But when i try to open it it gives me below error.
  • An internal server error has occurred
    An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. 

    Thank you again for your patience and assistance. And thanks for using salesforce.com! 
  •  
  • Thanks
  • Anupam

    Error ID: 1281456891-49957 (-1437854107)
  • January 14, 2015
  • Like
  • 1
Hi 

I am following the lighting web component trailhead (https://trailhead.salesforce.com/content/learn/projects/quick-start-lightning-web-components/create-a-hello-world-lightning-web-component ).
I created the web component, but when i try to add it to the home component, the custom web component is not showing and cannot add it to the home page. The helloworld.js-meta.xml file is same as what metioned in the trailhead account.
I am doing this in my trailhead playground. Any help on this will be highly appreciated
  • March 11, 2019
  • Like
  • 0

Hi All.. I am working in using Apex language in writing some application for Salesforce. I wish to perform PROFILING and CODE ANALYSIS/REVIEW for the given apex classes & triggers.

 

Can anyone suggest if Salesforce development platform supports an in-built PROFILER and CODE ANALYSIS/REVIEW tools? Also, pointers for it's starter guide documentation.

 

Best regards.

Hi there, 
i installed the Survey Force App from the appexchange market. Because the app is not supported i want to unterstand  the "main Code" and the basics. I cant find the standard controller "survey__c". I didnt know that for each custom object is automatically created a standard controller.  Is there a way to view the standardcontroller ?  

Thanks for your help !
I wrote a class 
public with sharing class SlackOpportunityPush {
    
    
    // To publish Opportunity values in form of a String//
    public static final String slackURL = 'https://hooks.slack.com/services/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';
    
    public class Oppty {
        @InvocableVariable(label='Opportunity Name')
        public String opptyName;
        
        @InvocableVariable(label='Owner')
        public String Owner;
        
        @InvocableVariable(label='Opportunity Amount')
        public String Amount;
        
        @InvocableVariable(label='Account Development Owner')
        public String AccountDE;
        
        @InvocableVariable(label='Account')
        public String Account;
    }
     
    @InvocableMethod(label='Push to Slack')
    
    public static void postToSlack(List<Oppty> oppties) { 
        Oppty o = oppties[0]; // If bulk, only post first to avoid overloading Slack channel
        Map<String,Object> msg = new Map<String,Object>();
        msg.put('text',  '\n Opportunity Won !  Congrats to Opportunity Owner !  :-  ' +o.Owner +   '\n and Account Development Owner:-  '+ o.AccountDE + '\n who just closed Opportunity:-  ' +o.opptyName +   '\n associated to Account:- ' + o.Account +'\n for Opportunity Amount:- $ ' + o.Amount);
        
        System.debug('Called msg.put');
        System.debug('OpportunityOwner '+o.Owner);
        System.debug('OpportunityAccount '+o.Account);
        System.debug('OpportunityAmount '+o.Amount);
        
        
        msg.put('mrkdwn',true);
        String body = JSON.serialize(msg);    
        System.enqueueJob(new QueueableSlackCall(slackURL,'POST',body));
    
    
    
    }
     
    public class QueueableSlackCall implements System.Queueable, Database.AllowsCallouts {
         
        public final String url;
        public final String method;
        public final String body;
         
        public QueueableSlackCall(String url,String method,String body) {
            this.url = url;
            this.method = method;
            this.body = body;
        }
         
        public void execute(System.QueueableContext ctx) {
            HttpRequest req = new HttpRequest();
            req.setEndpoint(url);
            req.setMethod(method);
            req.setBody(body);
            Http http = new Http();
            HttpResponse res = http.send(req);
        }
 
    }
    
}
Test class 
@isTest
private class SlackOpportunityTest {
    

static testMethod void testpostToSlack() {
SlackOpportunityPush.Oppty opt = new SlackOpportunityPush.Oppty();
opt.opptyName = 'Unit Test Opt';
opt.Owner = 'Unit Test Owner';


List<SlackOpportunityPush.oppty> lis = new List<SlackOpportunityPush.oppty>();
lis.add(opt);
SlackOpportunityPush.postToSlack(lis);

System.assertEquals(lis, lis); 
    
}
     
}

Code coverage is now 100% but while deploying the classes I get error:

​Methods defined as TestMethod do not support Web service callouts 
Stack Trace: null
Hi,

I need fill some columns with the value of the same field, but until now I can't make this work. So I wondering if I can use a variable of type list to get all the informations that I need and display in a table that each value will be separated by <tr><td>VALUE[0]</td></tr>
is it possible?

Best Regards
Rafael
Hi ,

I have follow requirement ... 

Create utility class to manage currency rate and Write trigger to fetch the currency value by passing currency("USD") as input.

I am new to development , little struggling while create a class.

Could anyone please give me  a sample code of ' utility class to manage currencey rate '
I want to create Opportunity Share records for two custom fields "Manager" and "Senior Manager"  lookup to User on Opportunity object. 

My Batch job is working as expected and creating those record perfectly. 

But, the issue is in Test Class:
  • I have created one createOpportunity() method, and create two Opportunities. 
  • Both the opportunities have Manager / Senior Manager field populated with User. 
  • Now, when I run this method, It will cover my Batch job and create sharing records ( that I can debug in batch job).
  • If I am trying to query those sharing record in Test Class using below query, it is giving 0 records. 
  • SELECT Id, manager__c, senior_manager__c, rowcause from Opportunity. 
Any ideas please. 
Hello All,

I am in need for Salesforce Freelance developer who can develop app and make it available on App exchange for others to use it. Knowledge of App development , Making it available on App Exchange , API and Apex programming needed.  

Please let me know if any body interested so that i can send the details .

Thanks
Pavan
I want to create a form which contains attributes about the profile of a Doctor.
I want to add an attribute through which I can upload profile pic of the Doctor
from a folder which is on my local disk. And I also want to display the images of all registered Doctors on other VF page.

I need help on this. 
Hi

I just activated namespace prefix in my developer account, and after that i am not able to access my project in eclipse or mavensmate force.com IDE. I also tried creating new project and was not successfull. I am getting read time out error while fetching the metadata in eclipse. 
I am able to login successfully through browser. 
See the error message belowUser-added image
  • March 11, 2016
  • Like
  • 0
Hi Experts,
 
Please find below Class, Trigger, and Test Class.
At present with my test class, it cover class with 33% and Trigger 0% need test class code cover help.
Please anyone help me.
 

Apex Class:


public with sharing class TaskTriggerHandler {
 
    private boolean m_isExecuting = false;
    private integer BatchSize = 0;
 
    public TaskTriggerHandler(boolean isExecuting, integer size) {
        m_isExecuting = isExecuting;
        BatchSize = size;
    }
   
    public void OnAfterUpdate(Map<ID, Task> newRecordMap, Map<ID, Task> oldRecordMap) {
       
        //if one Task related to WorkflowInstance was closed, clase all others Tasks related to the WorkflowInstance
        set<String> workflowInstanceIds = new set<String>();
       
        Schema.DescribeSObjectResult result = Workflow_Instance__c.SObjectType.getDescribe();
       
        String prefix_WorkflowInstance = result.getKeyPrefix();
       
        for(Id newRecordId: newRecordMap.keySet()){
            Task newRecord = newRecordMap.get(newRecordId);
            Task oldRecord = oldRecordMap.get(newRecordId);
            if(newRecord.IsClosed && !oldRecord.IsClosed && newRecord.WhatId != null && String.valueOf( newRecord.WhatId ).substring(0,3) == prefix_WorkflowInstance ){
                workflowInstanceIds.add(newRecord.WhatId);
            }
        }
        if(workflowInstanceIds.size() > 0) WorkflowUtil.closeTasks( workflowInstanceIds );
       
    }
}
 
 
 
Trigger:
 
trigger TaskTrigger on Task (after update) {
    TaskTriggerHandler handler = new TaskTriggerHandler(Trigger.isExecuting, Trigger.size);
    if(Trigger.isUpdate && Trigger.isAfter)  handler.OnAfterUpdate(Trigger.newMap, Trigger.oldMap);
}
 


 
Test Class:
 
@isTest
private class TaskTriggerHandlerTest {
 
    @isTest
    private static void TaskTriggerHandlerTest(){
       
        User u = [select id,Primary_UBE_Id__c from User where id=:UserInfo.getUserId()];
        u.Primary_UBE_Id__c = '114';
        update u;
 
        boolean m_isExecuting = false;
       
        //m_isExecuting = isExecuting;
        //BatchSize = size;
 
        Test.startTest();
        Test.stopTest();
    }
   
    @isTest
    private static void OnAfterUpdateTest(){
       
        User u = [select id,Primary_UBE_Id__c from User where id=:UserInfo.getUserId()];
        u.Primary_UBE_Id__c = '114';
        update u;
      
        Request__c request = new Request__c(name = 'test');
        insert request;
       
        Workflow_Instance__c workflowInstance = new Workflow_Instance__c(Request__c = request.Id);
        insert workflowInstance;
       
        Task told = new Task(Ownerid = U.id, Subject = 'Test', Whatid = workflowInstance.id, Status = 'Pending', Priority = 'Low', Description = 'Test');
        insert told;
       
        Task tnew = new Task(Ownerid = U.id, Subject = 'Test', Whatid = workflowInstance.id, Status = 'Closed', Priority = 'Low', Description = 'Test');
        insert tnew;
        
        Map<ID, Task> newRecordMap = new map<ID, Task>();       
        Map<ID, Task> oldRecordMap = new map<ID, Task>();
       
        set<String> workflowInstanceIds = new set<String>();
       
        Test.startTest();
            TaskTriggerHandler handler = new TaskTriggerHandler(Trigger.isExecuting, Trigger.size);
            //if(Trigger.isUpdate && Trigger.isAfter)  handler.OnAfterUpdate(Trigger.newMap, Trigger.oldMap);
        Test.stopTest();
    }
 
}
 

What is the difference between "Static" and "Transient" variables with respect to VISUALFORCE Page only.
Both are aren’t transmitted as part of the view state for a Visualforce page. Then what makes difference?

Below is the sample code I have written to understand this concept. But not understanding the exact difference.

VF Page Code
<apex:page controller="ViewStateVFCon" action="{!Method1}">
<apex:form >
<apex:pageBlock id="pb">
<apex:pageBlockTable value="{!StaticVar}" var="Tab1">
<apex:column headervalue="Record ID">
<apex:outputText value="{!Tab1.id}"/>
</apex:column>
<apex:column headervalue="Record Name">
<apex:outputText value="{!Tab1.Name}"/>
</apex:column>
</apex:pageBlockTable>


<br/><br/><br/><br/><br/><br/><br/><br/><br/>


<apex:pageBlockTable value="{!transeintVar}" var="Tab2">
<apex:column headervalue="Record ID">
<apex:outputText value="{!Tab2.id}"/>
</apex:column>
<apex:column headervalue="Record Name">
<apex:outputText value="{!Tab2.Name}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>

<apex:commandButton action="{!Method2}" title="Refresh" value="Refresh" reRender="pb"/>
</apex:form>

</apex:page>

VF Controller
public with sharing class ViewStateVFCon {
    public static List<Account> StaticVar {get;set;}
    public transient List<Account> transeintVar {get;set;}
    public void Method1 (){
        system.debug('Action Method1 from Page Action==    ');
        StaticVar = [select id, name from Account limit 20];
        transeintVar = [select id, name from Account limit 20];
    }
    public pageReference Method2 (){
        system.debug('Action Method2 from Command Button==    ');
        return null;
    }
}

 

Thanks Folks..
Syed Moosa Nazir TN
smartmoosa@gmail.com

<td>
<apex:inputfield value="{!qli.Batches_No__c}" style="width:25px;">
<apex:actionSupport event="onchange" rerender="pb,op" />
</apex:inputfield>
<apex:outputPanel id="op" >                                     
<apex:outputField value="{!qli.Batches_No__c}" />
</apex:outputPanel>
</td> 
<td>
<apex:commandlink Value="Add Batch" action="{!addBatch}" rerender="pb" styleclass="btn" style="text-decoration:None;padding-top:5px;" >
<apex:param assignTo="{!qliRowNum}" value="{!rowNum}" name="qliRowNum" /> 
<apex:param assignto="{!Batchesnumber1}" value="{!qli.Batches_No__c}" name="Batchesnumber1"/>  
</apex:commandlink>

It takes some time to load after changing the value  .I want immediate action after giving input .when i click the button it has to send the param values.