• Dimond
  • NEWBIE
  • 195 Points
  • Member since 2013

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 50
    Replies
Hello everyone,
I have a requirement to add a pop up to a standard page. When someone creates a new Lead and the Siret Code (custom field) is the same a the Siret Code of an existing account, a pop up should appear on the page, indicating that this Siret is already used.
Do you know how I could do this?
I thought about using a trigger, a custom controller, a controller extension or anything but I don't know how to articulate all of them.

Thank you for your help!
Marine
Might seem like a dumb question but I would like to confirm this with the community.

I am checking inbound data from another system that inserts (essentialy) a CSV into a custom object that I have created. I  have multiple validity checks that run on the data and I would like to use multiple methods of the same class to analyze the inbouund data.

So - if pass trigger.new to say - method 1 - which makes changes to the trigger and then in the very next line pass the trigger to mthod 2, are the changes made in method 1 preserved and visible by method 2?
This seems like it should be something I should know but I have never actually done this.

Many thanks
Can some one shed light on the best way to achieve this ?
I want to get the value of a text field from the ParentAccount in an Account Heirarchy on Contact record.   

Contact > Account > ParentAccount > 'text field' 

I am thinking of creating a formula field on Contact  with Psedocode ..

on Contact record if Account field is not null > check if the Account related to the contact, has a parent Account. if yes, populate the parent accounts customtextfield value on Contact
Hi everyone,

I need to figure out how to make calls to Cybersource for payments and refunds in Apex, and I have the credentials to do so, but I'm not sure how to implement it.

Does anyone have any sample/simple code that accomplishes one of these? I don't know how to build the request and the errors I receive are all 'XML Parsing Error'.

Any help at all would be great.
I am trying to get some information about a specific user in order to run a test against my code.  The first query runs fine and I can get the associated Contact Id for the user, but when I try to get the Oracle_Account_Number__c for the contact in the second query it returns 0 rows.  If I copy the SOQL select statement from the debug logs and run it manually it returns the correct information, so the syntax seems to be correct.

Does anyone see any issues or know why I'm getting no results on the second query?
@isTest
public class myTestMethod {

    static testmethod void testupdateLineItem()
    {     
        User u = [SELECT Id FROM User WHERE UserName='community.test1@example.com'];
        System.runAs(u)
        {
            ApexPages.StandardController sc = new ApexPages.StandardController(new Case());
  			m_Case_Details_Apex test = new m_Case_Details_Apex(sc); 
     
            //get the contact ID based on the named user
            string curUserNameQry = 'SELECT ContactId FROM User where username = \'' + userinfo.getusername() + '\'';
            User curContactId = Database.query(curUserNameQry);
            
            //get the Oracle Account number associated with the Contact ID
            string oracleAcctNumQry = 'SELECT Id,Oracle_Account_Number__c from Contact where Id = \'' + curContactId.ContactId + '\'';
            Contact oracleAcct = Database.query(oracleAcctNumQry);
            string oracleAcctNum = oracleAcct.Oracle_Account_Number__c;  
        }        
    }

 

hi all, 

after looking up and down, I am unable to find out whether pricebooks are allowed to be shared using apex. everything i've seen leads me to think that it is not currently possible. please let me know if you've discovered a way. thanks in advance!

  • November 08, 2013
  • Like
  • 0
Is it possible to pass a field value from a record to an iframe hosted inside a lightning component?

I have built an iframe inside a lightning component. The iframe is a link to a database that contains rows of records that are related to the Account object in Salesforce, but only lives in the database, not salesforce.

What I am trying to do is pass the value of a field called account number into the url of the iframe, so that the values presented in the iframe are sorted according to the field value being presented by the current active record in salesforce.
Hi,

Amost there with unit testing of my first Aura Component, however I am stuck with testing of 2 functions. The first finds all the tasks assigned to current user and the second updates a task to Status=Completed.

First function:
@AuraEnabled
    public static List<Task> getTasks(Id oUser){
        System.debug('oUser'+oUser);
       List<Task> taskList = [SELECT Id,Subject,Description,OwnerId,ActivityDate,Who.Name,Priority,Status,Type,AL_Assigned_To__c
                              FROM Task
                              WHERE OwnerId=:oUser AND ActivityDate <= NEXT_N_DAYS:3 AND Status != 'Completed'
                              ORDER BY ActivityDate ASC
                              LIMIT 7];
       System.debug('taskList: ' + taskList);
        return taskList;
    }
Second function:
@AuraEnabled
    public static void updateDetails(List<String> lstRecordId) {
        List<Task> lstUpdate = new List<Task>();
        for(Task t : [SELECT Id, Status FROM Task WHERE Id IN : lstRecordId]){
            t.Status = 'Completed'; // fields to update
            lstUpdate.add(t);
        }
        if(lstUpdate.size() > 0){
            update lstUpdate;
        }
    }

I have done the Trailhead Apex Testing (https://trailhead.salesforce.com/content/learn/modules/apex_testing?trail_id=force_com_dev_beginner) but maybe I'm not getting it or it doesn't cover what I'm trying to test here.

Here is where I'm at in the first test:
@isTest static void testGetTasks() {
        Task taskt = new Task(Subject='Test Task', OwnerId=UserInfo.getUserId(), Status='Not Started');
        insert taskt;

    }

Any help is really appreciated.

Thanks,
Michael
Hello Peeps,

I have two objects, claim and claim line items. I want to move the status of claim to rejected if all of the claim line items related to the claim are rejected, but not if only 1 or two are rejected. 

I've made a checkbox formula field on the claim object, but i'm not sure how to test whether all claim line items = rejected (rejected being in the picklist fields for claim line items.) 

Any help is much appreciated!
I have a need to keep a few fields on contact records in sync with an external system (name, email, etc...) and want to trigger an external API to do so when the record is edited and saved. An error is thrown when trying to perform this action since APIs are not allowed to be called as part of a record edit trigger.

The only way I can think to accomplish this is to expose a custom button or link to trigger the update manually. I'd like this to be automatic if possible.

Has anyone been able to work around this or suggest a different way to get this done?

Thank you in advance for your suggestions.
Hi,

In one of my interview ,the interviewer asked to explain an application in apex from front ent to back end.

I didnt get his requirement. what he wanted . I have worked in apex at backend that is trigger, Batch classes. what is frond end development in Apex? Can somone explain?
I'm trying to call the Amazon S3 API from Apex, but keep getting a

System.HttpResponse[Status=Forbidden, StatusCode=403] error. 

I know my end-points, key and secret are correct - as I pasted them directly from a working Postman example.

Can anyone see issues with my code?

Thanks!
 
public  list<string> rtnBucketItems(string bucketName, string key, string secret) {
		if(bucketName==null) 	bucketName 	= '******************************';
		if(key==null) 			key 		= '******************************';
		if(secret==null)		secret		= '******************************';

		String currentTimestamp = datetime.now().formatGmt('EEE, dd MMM yyyy HH:mm:ss Z');

		list<string> bucketItems = new list<string>();

		Http http = new Http();
		HttpRequest request = new HttpRequest();
		request.setMethod('GET');
		request.setHeader('Host','******************************.s3.amazonaws.com');
		request.setHeader('Content-Encoding', 'base64');
		request.setHeader('Date',currentTimestamp);
		request.setEndpoint('https://******************************.s3.amazonaws.com');

		// Build and set Authorization Header
		string stringToSign = 'GET\n\n\n' + currentTimestamp + '\n\n/' + bucketName;
		string stringSigned = rtnSignedString(stringToSign, secret);
		string authHeader = 'AWS' + ' ' + key + ':' + stringSigned;
		request.setHeader('Authorization', authHeader);

		HttpResponse response = http.send(request);
		system.debug('response='+response);

		return bucketItems;
	}


	public string rtnSignedString(string inString, string secret) {
		string signedString;
		Blob mac = Crypto.generateMac('HMACSHA1',blob.valueOf(inString),blob.valueOf(secret));
		signedString = EncodingUtil.base64Encode(mac);
		return signedString;
	}



 
Hello everyone,
I have a requirement to add a pop up to a standard page. When someone creates a new Lead and the Siret Code (custom field) is the same a the Siret Code of an existing account, a pop up should appear on the page, indicating that this Siret is already used.
Do you know how I could do this?
I thought about using a trigger, a custom controller, a controller extension or anything but I don't know how to articulate all of them.

Thank you for your help!
Marine
I am wanting to set up REST web services inside of Salesforce that can get, create, and change records for a particular object (leads in this case) whenever it is invoked. I will be invoking these methods from an external website. The POST (create) method I will be using is shown below. I will obviously be adding functionality to the web services themselves. I am only looking to figure out how to actually call them rather than how to write them.
@RestResource(urlMapping='/lead/*')
global class MyWebService {
    @HttpPost
    global static id postLead(string firstName, string lastName, string leadSource, string status) {
        lead newLead = new Lead();
        newLead.FirstName = firstName;
        newLead.LastName = lastName;
        newLead.LeadSource = leadSource;
        newLead.Status = status;
        insert newLead;
        return newLead.id;
}
Then in my javascript (jQuery allowed) code on the external site, I would presumably be creating HttpRequest objects that call these methods; however, I can't seem to get anywhere on this topic. I've tested a plethora of different parameters, but my general code is along the lines of
$.ajax(
    method:"get",
    cache:false,
url:"https://myinstance.lightning.force.com/services/apexrest/lead/leadIdHere",
    success: function(data) {
       alert(data);
    }
);
I know that this is in part because you need to authenticate, but I can'r seem to figure out what the URI for that method would be, not how to retain it. I've tried going through this with JSForce (https://jsforce.github.io) but haven't had any luck there (although I was able to get login authentication working with that.

I am just looking to call a simple REST web service that has been written inside of Salesforce from an external webpage using JavaScript.
 
Might seem like a dumb question but I would like to confirm this with the community.

I am checking inbound data from another system that inserts (essentialy) a CSV into a custom object that I have created. I  have multiple validity checks that run on the data and I would like to use multiple methods of the same class to analyze the inbouund data.

So - if pass trigger.new to say - method 1 - which makes changes to the trigger and then in the very next line pass the trigger to mthod 2, are the changes made in method 1 preserved and visible by method 2?
This seems like it should be something I should know but I have never actually done this.

Many thanks

Hello I need help writing a tet class for a trigger. 

Trigger-
 

trigger addPTMplc on jstcl__PlacementTeamMember__c (after insert) {

    List<ID> listIds = new List<ID>();
    
    for(jstcl__PlacementTeamMember__c ptm : Trigger.new){
        listIds.add(ptm.jstcl__Placement__c);
    }
    List<String> lstNames = new List<String>();
    List<ts2__Placement__c> plcList = [SELECT Id, ts2__Filled_By__c FROM ts2__Placement__c WHERE Id IN :listIds];
    for(jstcl__PlacementTeamMember__c ptm : [SELECT jstcl__User__r.name , jstcl__SplitPercent__c From jstcl__PlacementTeamMember__c WHERE jstcl__Placement__c IN :listIds AND jstcl__CommissionPlan__r.name LIKE '%Recruiter%' ORDER BY jstcl__SplitPercent__c DESC NULLS LAST LIMIT 1]){
        
        if(lstNames.contains(ptm.jstcl__User__r.Name)){

        }
        else{
            lstNames.add(ptm.jstcl__User__c);
        }
    for(integer i=0;i<plcList.size();i++){
        String names = string.join(lstNames, ', ');
        plcList[i].ts2__Filled_By__c =names;
        }
    }
    update plcList;
    
    
    List<ID> listIds2 = new List<ID>();
    
    for(jstcl__PlacementTeamMember__c ptm2 : Trigger.new){
        listIds2.add(ptm2.jstcl__Placement__c);
    }
    List<String> lstNames2 = new List<String>();
    List<ts2__Placement__c> plcList2 = [SELECT Id, ts2__Sales_Rep__c FROM ts2__Placement__c WHERE Id IN :listIds2];
    for(jstcl__PlacementTeamMember__c ptm2 : [SELECT jstcl__User__r.name From jstcl__PlacementTeamMember__c WHERE jstcl__Placement__c IN :listIds2 AND jstcl__CommissionPlan__r.name LIKE '%Account Executive%' ORDER BY jstcl__SplitPercent__c DESC NULLS LAST LIMIT 1]){
        
        if(lstNames2.contains(ptm2.jstcl__User__r.Name)){

        }
        else{
            lstNames2.add(ptm2.jstcl__User__c);
        }
    for(integer i=0;i<plcList2.size();i++){
        String names2 = string.join(lstNames2, ', ');
        plcList2[i].ts2__Sales_Rep__c =names2;
        }
    }
    update plcList2;
}

What I have so far for the test class-
@isTest(SeeAllData=true)
public class addPTMplcTest {
    private static testMethod void testPTM(){
 ADP_Department__c adp = new ADP_Department__c();
        adp.Name = 'Georgia';
        insert adp;
         Contact con=new Contact(
            FirstName='fname',
            LastName = 'lname',
            Email = 'email@gmail.com',
            Phone = '9743800309'); 
        insert con; 
       
        ts2__Job__c job = new ts2__Job__c();
        job.Name = 'Software Engineer';
        insert job;
        Account acc = new Account(Name = 'Test Company');
        insert acc;
        ts2__HolidayCalendar__c hcal = new ts2__HolidayCalendar__c();
        hcal.Name= 'Holiday Calendar';
        insert hcal;
        Labor_Category__c lcat = new Labor_Category__c(Name='Software Engineer 1');  
        insert lcat;
         ts2__Placement__c plc = new ts2__Placement__c();
        plc.ts2__Job__c = job.Id;
        plc.Contractor_Type__c = 'Test';
        plc.Onboarding_Method__c= 'Staff Augmentation';
        plc.ts2__Start_Date__c= Date.newInstance(2019, 1, 7);
        plc.ts2__End_Date__c= Date.newInstance(2019, 2, 15);
        plc.jstcl__HireType__c= 'W2';
        plc.ADP_Department__c= adp.Id;
        plc.ts2__Bill_Rate__c= 60.00;
        plc.ts2__Pay_Rate__c= 30.00;
        plc.jstcl__Invoice_Batch__c= 'Placement';
        plc.ts2__Client__c= acc.Id;
        plc.ts2__Hiring_Manager__c= con.Id;
        plc.jstcl__TimecardApprover__c= con.Id;
        plc.jstcl__HolidayCalendar__c= hcal.Id;
		plc.State_Worked_In_Non_TFI_Placements__c= 'GA - Georgia';
        plc.jstcl__Overtime_Bill_Rate__c= 60;
        plc.jstcl__Burden__c= 0.20;
        plc.jstcl__Accounts_Receivable_U__c= '00537000005d7F2AAI';
        plc.jstcl__Terms__c= 'Net 60';
        plc.ts2__Employee__c= con.Id;
        plc.Labor_Category__c= lcat.Id;
        plc.Placement_Team_Member_List__c= 'Test User';
        insert plc;
        User u = new User(
 	    ProfileId = [SELECT Id FROM Profile WHERE Name = 'National Sales'].Id,
	     LastName = 'last',
    	 Email = 'abc@123.com',
	     Username = 'abc@123.com',
    	 CompanyName = 'TEST',
   	 	 Title = 'title',
   	 	 Alias = 'alias',
   		 TimeZoneSidKey = 'America/Los_Angeles',
     	 EmailEncodingKey = 'UTF-8',
    	 LanguageLocaleKey = 'en_US',
    	 LocaleSidKey = 'en_US'
		);
         
        jstcl__TG_Commission_Plan__c cp = new jstcl__TG_Commission_Plan__c(name = 'National Vertical Manager (NVM or NAM)' );
        insert cp;
        
        
        Test.startTest();
        System.debug('>>>>>>>>> Starting Test');
        jstcl__PlacementTeamMember__c ptm = new jstcl__PlacementTeamMember__c(jstcl__Placement__c = plc.Id,
                                                                              jstcl__User__c = u.Id,
                                                                              jstcl__CommissionPlan__c = cp.Id,
                                                                              jstcl__SplitPercent__c = 100);
        insert ptm;
        System.assertEquals(ptm.jstcl__User__c, plc.Placement_Team_Member_List__c);
        System.debug('>>>>>>>>> Ending Test');
        Test.stopTest();

    }
}

​​​​​​​
Hi All ,
I'm new to Salesforce and i wonder how i can conditionally display visualforce page on account page upon that button click as illustrated on image .User-added image
Hi everyone,

I need to figure out how to make calls to Cybersource for payments and refunds in Apex, and I have the credentials to do so, but I'm not sure how to implement it.

Does anyone have any sample/simple code that accomplishes one of these? I don't know how to build the request and the errors I receive are all 'XML Parsing Error'.

Any help at all would be great.