• Gaurav Sharma 472
  • NEWBIE
  • 173 Points
  • Member since 2019

  • Chatter
    Feed
  • 6
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 33
    Replies
Hello,

I have created a trigger on Order object to update an account's custom field (Chiffre_d_affaire__c) when an order has been made.
But when trying to add a product to the order. I have an error:

User-added image

How could I fix that error?
thank you

here is my trigger:
trigger UpdateAccountCA on Order (after update) {
	
    Map<Id, Decimal> mAccAmount = new Map<Id, Decimal>();

    //Iterate through each Order 
    for(Order o : Trigger.new) {
        Decimal d = mAccAmount.get( o.AccountId );
        d += o.TotalAmount;

        mAccAmount.put( o.AccountId, d );
    }
    List<Account> lAccs = [SELECT Id, Chiffre_d_affaire__c FROM Account WHERE Id = :mAccAmount.keySet()];

    //Iterate through each List of Accounts 
    for(Account acc : lAccs){
        acc.Chiffre_d_affaire__c = acc.Chiffre_d_affaire__c + mAccAmount.get(acc.Id);
    }

    update lAccs;  
}

 
Hi,

I'm new to SOQL. I'm working on Lookup Rollup Summaries and on Relationship Criteria, I would to put condition where
A__c contains Apple
AND
B__c doesn't contain Bird

When I tried on code below, its doens't work
A__c LIKE '%Apple%' AND  
NOT(B__c LIKE '%Bird%')

But when I tried with one condition for each of them, its works perfectly.

Could you please help what have I done wrong please as I'm really new to SOQL

thank you
I have written a trigger on lead to enhance the lead conversion process. When converting a lead, the user has the ability to create a new account or choose existing. If a user tries to create a new account we need to run validation to see if there is already an account with the same custom field value (Company_Id__c). If there is another account with the same Company_Id__c, then we need to show an error message to the user.
But I got stuck here in code to get to know how to check that user want to create new account or selected existing account?

Here is my code.
 
trigger LeadTrigger on Lead (After Update) {
	Map<Id, Lead> = Trigger.oldMap;
	for(Lead lead : Trigger.new){
		if(lead.isConverted && oldMap.get(lead.id).isConverted) continue; //only process newly converted leads
		//check converted leads only.
		if (oldMap.get(lead.Id).isConverted == false && lead.isConverted) {
			//How to check in code that user already existing account or new one he want to create.
		}
	}
}
Please help
  • July 13, 2020
  • Like
  • 0
Hello

I have a visualforce page (CustomerServiceReport) that uses the standard Account controller and an extension (CustoemrServiceReportExtension) to pull through some basic information about cases relating to that Account (i.e. number of cases raised in last 30 days, number closed, etc). 

I want to expand on this to show the contacts and number of cases they have raised in the last 30 days (ideally restricted to the top 10 with ordered by highest to lowest). For the life of me I don't seem to be able to get it working. All I will need is the Contact's Name the case is raised under and the number of cases they have raised.

I'm fairly new to Visualforce and Apex so still trying to get to grips with it. This is a bit of a side-project (which may make my employer's life a bit easier) that I figure may help me improve my skills. 

Anyone able to help me out? I'm fine with it been a secondary extension if it makes things easier/tidier.  
Hi,

I would like to display a users based on selected department.

1. I am using 2 objects for this functionality 
              A. User Assignment  (here user & department is a picklist )
              B. Department 
2. I need to display a users based on selected department (users are mapped in User Assignment Object)

I tried in my way, I can return from a class but list of users is not displaying while onchange.

Please review my code and let me know where i did a mistake.

Component.
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickActionWithoutHeader" controller="GD_CreateQuoteTeam" access="global">
    
      
    <aura:attribute name="recordId" type="String" />
   <aura:attribute name="depts" type="list"/>
    <aura:attribute name="usersOrg1" type="list"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <div class="slds"> 
        <div class="slds-form-element" align="center"> 
            <h3 class="slds-section-title--divider"><b>Add Quote Team Members</b></h3>
        </div>
    </div>
    <br/>
    <div class="container-fluid">
        <table class="slds-table slds-table_bordered slds-table_cell-buffer">
            <thead>
                <tr class="slds-text-title_caps">
                    <th scope="col">
                        <!--<div class="slds-truncate">Sr.no</div>-->
                    </th>
                     <th scope="col">
                        <div class="slds-truncate" title="Team Role"><b><span style="color: red;">*</span>Department</b></div>
                    </th>
                    <th scope="col">
                        <div class="slds-truncate" title="User"><b><span style="color: red;">*</span>User</b></div>
                    </th>
                    
                </tr>
            </thead>
            <tbody>    
                <aura:iteration items="{!v.QuoteList}" var="quote" indexVar="index">
                    <tr>
                        <td> 
                            <br/>{!index + 1}
                        </td>
                        <td>
                            <lightning:select value="{!quote.GD_Department__c}" onchange="{!c.onChangeVal}">
                                <option value="">-- None --</option>
                                <aura:iteration items="{!v.depts}" var="dept" >
                                    <option  value="{!dept.value}" >{!dept.label}</option> 
                                </aura:iteration>
                            </lightning:select>
                        </td>
                       
                        <td>
                            <lightning:select value="{!quote.GD_User__c}">
                                <option value="">-- None --</option>
                                <aura:iteration items="{!v.usersOrg1}" var="user" >
                                    <option  value="{!user.value}" >{!user.label}</option> 
                                </aura:iteration>
                            </lightning:select>
                        </td>
                        
                    </tr>
                    
                </aura:iteration>
            </tbody>
        </table>
    </div>
</aura:component>

Controller.JS
doInit: function(component, event, helper) {
        helper.getDepartmentPickList(component, event);
        helper.getUserOrgPickList(component, event);
    },

onChangeVal:function (component, event, helper) {
        var val = event.getSource().get("v.value");
        console.log('val'+val);
         alert('On Change' + val);
        var action = component.get("c.getSelectedUser");
        action.setParams({"sname":val});
        action.setCallback(this, function(result){
            var users = result.getReturnValue();
            component.set("v.usersOrg1", users);
        });
        $A.enqueueAction(action);
    },

Helper.Js
getUserOrgPickList: function(component, event) {
        var action = component.get("c.queryUsersOrg1");
            action.setCallback(this, function(data) {
                var result = data.getReturnValue()
				var opts = [];
			for (var i in result){
                console.log(i);
                    opts.push({
                        class: "optionClass",
                        label: result[i],
                        value: i
                    });
                }
                component.set("v.usersOrg", opts);
        });
        $A.enqueueAction(action);
        
    },

getDepartmentPickList: function(component, event) {
        var action = component.get("c.queryDepartments");
            action.setCallback(this, function(data) {
                var result = data.getReturnValue()
				var opts = [];
			for (var i in result){
                console.log(i);
                    opts.push({
                        class: "optionClass",
                        label: result[i],
                        value: i
                    });
                }
                component.set("v.depts", opts);
        });
        $A.enqueueAction(action);
        
    },



Apex Class
@AuraEnabled
    public static Map<String, String> queryUsersOrg1(string sname) {
        Map<String, String> usersOrg1 = new Map<String, String>();
        system.debug('sname' + sname);
        for(GD_User_Organization_Assignments__c usrOrg : [select ID, Name, GD_User__c,GD_Department__c,GD_Department__r.Name, GD_User__r.Name from GD_User_Organization_Assignments__c where GD_Department__c  =: sname]) {
        	//usersOrg.put('--None--', '-- None --');  
        	system.debug('usrOrg Query ***' +usrOrg.GD_User__r.Name + ' - ' + usrOrg.GD_Department__r.Name);
            usersOrg1.put(usrOrg.GD_User__c, usrOrg.GD_User__r.Name);     
        }
        return usersOrg1; 
    }


Thanks in Advance,
Soundar.
            

Hello,

I have implemented an integration through the REST-API and I'm able to “get”, “create” and “update” Account and Contact through the REST API.

The only thing I don’t know how to handle is the AccountContactRelations object. I think the “get” should work correctly using for example an URL “sobjects/Account/0012X000021VVYVQA4/AccountContactRelations/”  and I think my implementation is working correctly.  
But I don’t know how to create one through the REST-API.

Is
 chapter in the developer documentation https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_relationships.htm (https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_relationships.htm" style="color:#0563c1; text-decoration:underline" target="_blank" title="https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_relationships.htm) for this kind of object?

Best Regards
Bernhard Maehr

I am working on creating a new custom object called 'License Managment' that would automatically create a new record the first of every month. This way we have a 'snapshot' or history of our usuage.  I know you can pull these figures in a report, however is there a way to pull them into a field? 

The numbers I want to pull into a field are...
- Available Licenses
- Used Licenses
I am taking salesforce training in chennai as suggested by one of my friend as i want to grow up my career in salesforce only. In this project, I will work on the retail inventory management. I will deploy real-time tracking and analysis for the four different categories of product, inventory, sales, and customer. This is a multiple to multiple relationships, whenever a product is sold it has to be replaced in the inventory. I will list the products bought by the customer, the details of the customer and such other data. So, I want to know whether i am going in right path or not?
Hello,

I have created a trigger on Order object to update an account's custom field (Chiffre_d_affaire__c) when an order has been made.
But when trying to add a product to the order. I have an error:

User-added image

How could I fix that error?
thank you

here is my trigger:
trigger UpdateAccountCA on Order (after update) {
	
    Map<Id, Decimal> mAccAmount = new Map<Id, Decimal>();

    //Iterate through each Order 
    for(Order o : Trigger.new) {
        Decimal d = mAccAmount.get( o.AccountId );
        d += o.TotalAmount;

        mAccAmount.put( o.AccountId, d );
    }
    List<Account> lAccs = [SELECT Id, Chiffre_d_affaire__c FROM Account WHERE Id = :mAccAmount.keySet()];

    //Iterate through each List of Accounts 
    for(Account acc : lAccs){
        acc.Chiffre_d_affaire__c = acc.Chiffre_d_affaire__c + mAccAmount.get(acc.Id);
    }

    update lAccs;  
}

 
Hi,

I would like to add opportunities whose Stage and Type is New Opportunity and New Business. I have added a new account record and these opportunities should be linked to the newly created account record.

//Batch Class

global class BatchForAddingOpps implements Database.Batchable<sObject> {
    List<Opportunity> oppList {get;set;}
    global Database.QueryLocator start(Database.BatchableContext BC) {
        return Database.getQueryLocator([SELECT Name, Type, StageName, CreatedDate 
                                         FROM Opportunity 
                                         WHERE Type = 'New Business' AND StageName = 'New Opportunity']);
    }
    global void execute(Database.BatchableContext BC, List<Opportunity> oppList) {
        List<Opportunity> newList = new List<Opportunity>();
        for(Opportunity opp : oppList) {
            opp.StageName = 'Closed Lost';
        }
        update oppList;
        System.debug('newList'+oppList);
    }
    global void finish(Database.BatchableContext BC) {
        
    }
}

I've got the opportunities but unable to add these opportunities to newly created account record...Can someone help me achieve this...

Thanks in advance.
  • July 19, 2020
  • Like
  • 0
Hi all, I'm trying to create a button where the user can upload a pdf, and that pdf is then sent to the Docparser API.

What I currently have is the code from the Docparser API to send an Attachment object: https://github.com/Docparser/Docparser-Apex/blob/master/upload_document.apx

This would work, but I'm not sure how to get a pdf into an Attachment object, and I'm not sure if Attachment is even used in Apex anymore. There are "Salesforce Files" on Lightning which I have been able to manually upload pdfs to, but I'm not sure how to upload to/access them in code.

How do I get a pdf file into an Attachment or File (using an <apex:inputFile>)? What I need for sending information to Docparser is the name of the file and base64 encoded file data.

Thank you for any help.
Hi,

I have a custom lightning page,
There are set of opportunity products, which gets added as a record. Every record has a picklist value.

But in the event of 100 products, i need to manually go and set the picklist value, even if they are same.

What i want is, if i can have a checkbox at the lightning component, which when checked, will populate the same picklist value as selected on the first record, and still allows the user to change the picklist value for records he wants to.

This way it will be easier for him
Hi,

I'm new to SOQL. I'm working on Lookup Rollup Summaries and on Relationship Criteria, I would to put condition where
A__c contains Apple
AND
B__c doesn't contain Bird

When I tried on code below, its doens't work
A__c LIKE '%Apple%' AND  
NOT(B__c LIKE '%Bird%')

But when I tried with one condition for each of them, its works perfectly.

Could you please help what have I done wrong please as I'm really new to SOQL

thank you
I have written a trigger on lead to enhance the lead conversion process. When converting a lead, the user has the ability to create a new account or choose existing. If a user tries to create a new account we need to run validation to see if there is already an account with the same custom field value (Company_Id__c). If there is another account with the same Company_Id__c, then we need to show an error message to the user.
But I got stuck here in code to get to know how to check that user want to create new account or selected existing account?

Here is my code.
 
trigger LeadTrigger on Lead (After Update) {
	Map<Id, Lead> = Trigger.oldMap;
	for(Lead lead : Trigger.new){
		if(lead.isConverted && oldMap.get(lead.id).isConverted) continue; //only process newly converted leads
		//check converted leads only.
		if (oldMap.get(lead.Id).isConverted == false && lead.isConverted) {
			//How to check in code that user already existing account or new one he want to create.
		}
	}
}
Please help
  • July 13, 2020
  • Like
  • 0
Hi everyone,

Fairly new to SalesForce.
I have been successfully retreiving information through SOQL with the help of workbench.
I need to figure out a way to retrieve files linked to an opportunity.

In short I'm trying to retrieve the photos uploaded against an opportunity.

I managed to get some output by running the below query.
SELECT ContentDocumentId,Id,IsDeleted,LinkedEntityId,ShareType,SystemModstamp,Visibility FROM ContentDocumentLink WHERE LinkedEntityId = 'THE_OPPORTUNITY_ID'
Seems like there is another table that this info needs to be retrieved from.
Is there a way to retrieve a publicly accessible URL for the above files?
 
I have issues with a simple call to get records in Apex controller. I cant get the data in my LWC. The Apex Controller is being called correctly and the response is also correct.
 
import { LightningElement, wire } from 'lwc';

import LabelChooseTarget from '@salesforce/label/c.Choose_a_target';
import LabelCreateNewLabel from '@salesforce/label/c.Create_New';

import FIELD from '@salesforce/schema/Target_Configuration__c.Name';

import getAllConfigurations from '@salesforce/apex/ConfigurationController.getAllConfigurations';

const COLUMS = [
    {label : 'Name', fieldName : FIELD.fieldApiName, type: 'text'}
];


export default class ConfigurationSelector extends LightningElement {
    column = COLUMS

    label = {
        LabelChooseTarget
    };

    @wire(getAllConfigurations)
    configurations;

}
 
<template>
    <lightning-card  icon-name="custom:custom83" title={label.LabelChooseTarget}>

        <template if:true={configurations.data}>

        <lightning-datatable
            key-field="Id"
            data={configurations.data}
            colums={colums}>
        </lightning-datatable>

        </template>
    </lightning-card>
</template>



 
Hello

I have a visualforce page (CustomerServiceReport) that uses the standard Account controller and an extension (CustoemrServiceReportExtension) to pull through some basic information about cases relating to that Account (i.e. number of cases raised in last 30 days, number closed, etc). 

I want to expand on this to show the contacts and number of cases they have raised in the last 30 days (ideally restricted to the top 10 with ordered by highest to lowest). For the life of me I don't seem to be able to get it working. All I will need is the Contact's Name the case is raised under and the number of cases they have raised.

I'm fairly new to Visualforce and Apex so still trying to get to grips with it. This is a bit of a side-project (which may make my employer's life a bit easier) that I figure may help me improve my skills. 

Anyone able to help me out? I'm fine with it been a secondary extension if it makes things easier/tidier.  
Hi,

I would like to display a users based on selected department.

1. I am using 2 objects for this functionality 
              A. User Assignment  (here user & department is a picklist )
              B. Department 
2. I need to display a users based on selected department (users are mapped in User Assignment Object)

I tried in my way, I can return from a class but list of users is not displaying while onchange.

Please review my code and let me know where i did a mistake.

Component.
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickActionWithoutHeader" controller="GD_CreateQuoteTeam" access="global">
    
      
    <aura:attribute name="recordId" type="String" />
   <aura:attribute name="depts" type="list"/>
    <aura:attribute name="usersOrg1" type="list"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <div class="slds"> 
        <div class="slds-form-element" align="center"> 
            <h3 class="slds-section-title--divider"><b>Add Quote Team Members</b></h3>
        </div>
    </div>
    <br/>
    <div class="container-fluid">
        <table class="slds-table slds-table_bordered slds-table_cell-buffer">
            <thead>
                <tr class="slds-text-title_caps">
                    <th scope="col">
                        <!--<div class="slds-truncate">Sr.no</div>-->
                    </th>
                     <th scope="col">
                        <div class="slds-truncate" title="Team Role"><b><span style="color: red;">*</span>Department</b></div>
                    </th>
                    <th scope="col">
                        <div class="slds-truncate" title="User"><b><span style="color: red;">*</span>User</b></div>
                    </th>
                    
                </tr>
            </thead>
            <tbody>    
                <aura:iteration items="{!v.QuoteList}" var="quote" indexVar="index">
                    <tr>
                        <td> 
                            <br/>{!index + 1}
                        </td>
                        <td>
                            <lightning:select value="{!quote.GD_Department__c}" onchange="{!c.onChangeVal}">
                                <option value="">-- None --</option>
                                <aura:iteration items="{!v.depts}" var="dept" >
                                    <option  value="{!dept.value}" >{!dept.label}</option> 
                                </aura:iteration>
                            </lightning:select>
                        </td>
                       
                        <td>
                            <lightning:select value="{!quote.GD_User__c}">
                                <option value="">-- None --</option>
                                <aura:iteration items="{!v.usersOrg1}" var="user" >
                                    <option  value="{!user.value}" >{!user.label}</option> 
                                </aura:iteration>
                            </lightning:select>
                        </td>
                        
                    </tr>
                    
                </aura:iteration>
            </tbody>
        </table>
    </div>
</aura:component>

Controller.JS
doInit: function(component, event, helper) {
        helper.getDepartmentPickList(component, event);
        helper.getUserOrgPickList(component, event);
    },

onChangeVal:function (component, event, helper) {
        var val = event.getSource().get("v.value");
        console.log('val'+val);
         alert('On Change' + val);
        var action = component.get("c.getSelectedUser");
        action.setParams({"sname":val});
        action.setCallback(this, function(result){
            var users = result.getReturnValue();
            component.set("v.usersOrg1", users);
        });
        $A.enqueueAction(action);
    },

Helper.Js
getUserOrgPickList: function(component, event) {
        var action = component.get("c.queryUsersOrg1");
            action.setCallback(this, function(data) {
                var result = data.getReturnValue()
				var opts = [];
			for (var i in result){
                console.log(i);
                    opts.push({
                        class: "optionClass",
                        label: result[i],
                        value: i
                    });
                }
                component.set("v.usersOrg", opts);
        });
        $A.enqueueAction(action);
        
    },

getDepartmentPickList: function(component, event) {
        var action = component.get("c.queryDepartments");
            action.setCallback(this, function(data) {
                var result = data.getReturnValue()
				var opts = [];
			for (var i in result){
                console.log(i);
                    opts.push({
                        class: "optionClass",
                        label: result[i],
                        value: i
                    });
                }
                component.set("v.depts", opts);
        });
        $A.enqueueAction(action);
        
    },



Apex Class
@AuraEnabled
    public static Map<String, String> queryUsersOrg1(string sname) {
        Map<String, String> usersOrg1 = new Map<String, String>();
        system.debug('sname' + sname);
        for(GD_User_Organization_Assignments__c usrOrg : [select ID, Name, GD_User__c,GD_Department__c,GD_Department__r.Name, GD_User__r.Name from GD_User_Organization_Assignments__c where GD_Department__c  =: sname]) {
        	//usersOrg.put('--None--', '-- None --');  
        	system.debug('usrOrg Query ***' +usrOrg.GD_User__r.Name + ' - ' + usrOrg.GD_Department__r.Name);
            usersOrg1.put(usrOrg.GD_User__c, usrOrg.GD_User__r.Name);     
        }
        return usersOrg1; 
    }


Thanks in Advance,
Soundar.
            
Hi can anyone share code below requiremet :
{
  "Emp": {
    "Id": "a1K36000",
    "empName": {
      "value": "Life"
    },
    "empAge": {
      "value": " 40"
    },
    "Address": null,
  },
  "Manager": {
    "arrangementNumber": "S03434555",
    "payrollBenefit": {
      "value": "11"
    },
    "endOfEnrollment": "06/17/2020", 
    "isGIPolicyType": "YES",  
    "planType": {
      "value": " Issue"
    },
    "isSelect": "YES", 
    "totalNumber": 0 
  },
  
  My requirement is :
  In RestExplorer, Get Method, When i pass below URL # /services/apexrest/partyInquiry?recordId=a1K2F000000Wsom 
  I can get Results below Structure :
  
  EmpInfo
   --Id : a1K36000
     empName:Life
     empAge  : 40
     Address : null
 Manager 
    arrangementNumber: S03434555,
    payrollBenefit: : 11
    endOfEnrollment: "06/17/2020, 
    isGIPolicyType: "YES,  
    planType:  Issue
    isSelect: "YES", 
    totalNumber: 0 

Thanks
VRK
  • July 09, 2020
  • Like
  • 0
Hi Guys,

I tried a lot and stuck up in a loop, can any one kindly please help me?

When I select "Y" for Monday_Availability__c, then Pre_Vet_Reviews__c should be enabled. This is the code I have. Kindly help.

   <apex:pageBlock title="Availability">
    <div style="float:left; width: 800px; margin-right: 20px;">
        <apex:pageBlockTable value="{!ListValues}" var="a">
<apex:actionRegion > 
            <apex:inputField value="{!a.Monday_Availability__c}" id="pb1"/>
            <apex:actionSupport event="onchange" rerender="pb1" />
              </apex:actionRegion> 
</apex:pageBlockTable>
        </div>
<apex:pageBlock title="Core Categories">
        <div styleClass="labelCol vfLabelColTextWrap">
           <table border="1px" width="100%" height="80%" style="page-break-inside:auto;">
<apex:repeat value="{!ListValues}" var="a" >
                  <tr>
                       <th>Pre-Vet Reviews</th>
                       <th>180 Mins</th>
                       <td><apex:inputField value="{! a.Pre_Vet_Reviews__c}" rendered="{!a.Monday_Availability__c=='Y'}" required="{!a.Monday_Availability__c=='Y'}"/></td>
 </tr>
  </apex:repeat>
       </table>
             </div>
             </apex:pageBlock> 
Hello Team,

I am building one lightning page where I'm displaying Partner Name (Accounts) based on the user search. 
So, the UI looks like it has Name of the Partner, Address and a button. The functionality of button is when the user clicks on that it will so some additional information of the partner like description, partner Certification etc.

So, now what is happening when I'm clicking on button it is showing additional information of all the partners (which are coming from the search result) but what my requirement is, the button is clicked for which partner , it should display the description of only that partner and rest all the result should go away.

I hope I could able to explain my question.

Thanks