• Jay reddy
  • NEWBIE
  • 30 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 34
    Questions
  • 20
    Replies
Heya mates,

I'm trying to create multiple child records with the help of apex, when the parent record is created. My issue is there is picklist field on Child object with 20 values and when we create a parent record, the apex should create 20 different child records based on the picklist value on child object.

OBJECTS: CustomObjA, CustomObjB [Masterdetail]

I know below code is very ametuer, which explains my range in apex coding. Also, the code should be builkfied.
 
trigger CreateBuyingInfluence on CustomObjA (after insert)

 {
    List<CustomObjB> Childs = new List<CustomObjB>();

    for(CustomObjA a : trigger.new)
    {
       CustomObjB Child = new CustomObjB ();
       Child.SCOP__c = a.id;
       Child.Name = 'testName'; 

       Childs.add(Child);      
    }

    insert Childs;
}

 
When creating an Opportunity I'm trying to setup an opportunity record type/page layout that will automatically be applied based on the Account record type chosen. My users already choose from a drop down with creating an account, so I don't want them to have to do it again when creating an opportunity. it should just be assigned based off the account record type choosen dynamically.

Tried Workflows, PB ... didn't work! Can't use URL hack because of lightning. 
For instance, we have "Custom Object A" and "Custom Object B" (Master-detail relationship). And Custom Object A has Record Type 'A' & 'B', Custom Object B has Record Types 'A1' & 'B1'. So, whenever I create a custom object 'A' record with record type 'A' and try to create a child object (Cus. Object B) through related list of Cus. Object A, it should automatically select record type 'A1' of Cus. object 'B' and same with record type 'B1' of cus. object B.

If (Custom Object A's record RT is A ---> Then Custom Object B's record RT should 'A1')
If (Custom Object A's record RT is B ---> Then Custom Object B's record RT should 'B1')

I've tried PB, WF, VR... but doesn't meet my requirement cuz i need the logic to be applied while creating the records of Cus. Object B, not after creating the record (needed to be in ligtning). There's coding solution for this requirement (below is the link) but it doesn't work if we click "Cancel" or "Save & New" button. I really appreciate if anyone could help.
https://force201.wordpress.com/2011/05/21/automatically-setting-the-record-type-of-a-detail-object-based-on-the-record-type-of-its-master-object/ 
 
Hi all,

I have an email about Code changes required for Apex compiler. In that, one of the scenario is binding SCHEMA to objectname in the code.

Should I have to add/ modify map<Id, OpportunityLineItem> TO map<Id, Schema.OpportunityLineItem> in all codes??

I appreciate your help.



User-added image
Thanks
GR
Hello,

I'm getting javascript error when entering a text with line break in a field, which is mentioned in the javascript code. Is there a way to skip that error from a line break. I used JSENCODE but it's working for special characters only and not for line breaks. Below is the way I have defined the field in Javascript.
 
var field = '{!JSENCODE(Opportunity.Closing_instructions__c)}';
field = field.replace(/(/\r?\n|\r/),"");
Thanks,
GR
 
Hello,

Can anyone help how to add Upload / attach button in VF page. On clicking it it should allow uploading documents from local computer.

thanks,
Girish
Hello,
I need a help on having a conga custom button on Opportunity that would grab only quotelineitems from PRIMARY quote and put them in a pdf. I have query to pull the quote line items but need help on writing that soql query in the button.

Thanks,
GR

Hi All, this is a Lightning question.

I am wondering how to prepopulate / preset field values in a standard page layout using standard "New" functionality. Use case:

I have a Parent Object and a Child Object. The Child object should derive it's record type dynamically from the parent object.

    E.g. a picklist on the Parent has the values Type A, Type B, Type C

When a new child record is created from the parent, I would like to dynamically set the record type of the child to A, B, C.

The page layouts are different for each A, B and C. I would like to use the standard functionality of "New Child" to create these records. 

Quick Actions: do not allow dynamic binding of record type. They also do not have the capability to use standard page layouts. So having a unique button per record type is unacceptable. 

URL Hacks: Work great in classic - unsupported in LEX. 

Thanks in advance. 

Hello,

I have a requirement where I need to access Campaign Influence records in the Opportunity related list by SOQL query. Basically, I need to access it because I have custom object looking up to CAMPAIGN. And I want to show all opportunities in that custom object related list "Opportunities" upon on adding the Campaign in the custom object.

Thanks,
GR
Hello,

I have a requirement where we have Subscription products and in that some should be sold for definite time period [3 months] and the rest of the products from the similar category can be sold for any time period. For this I have created a CUSTOM SETTING for the products which should be sold for definite time period [3 months] but seems my logic is incorrect and throwing the same second error [see below in the code] for the products which are in CUSTOM SETTING. They do have different error.
 
Set<String> ExcludeSubProdIds = new Map<String, Product2> ([Select Name,ProductCode from Product2 WHERE  ProductCode IN: SubscriptionProducts__c.getAll().keySet()]).keySet();

for(Quotelineitem qli:QLIList){
if(qli.Product_Code__c.contains('SUB')) {
             if(ExcludeSubProdIds.contains(qli.Product_Code__c) && (qli.Number_of_Terms__c !=3 || decimavalue!=0) ){
             qli.adderror('Error. Please check dates');
             }  else if(!ExcludeSubProdIds.contains(qli.Product_Code__c) && (qli.Number_of_Terms__c==  0 ||decimavalue!=0))  {
             qli.adderror('Term Periods must be in whole months (for SUB products) and whole years  products.');
         }
             }
             }

 
Hi,

New bee.

I need to copy a custom field [formula field] at QuoteLineItem level to custom field [currency] at OpportunityLineItem level.

I tried to write the below trigger. It saved but not displaying any results.

I need to copy Total price with Total discount & Var at quotelineitem level to "total price discount" at OpportunityLineItem level.

trigger TotalPriceDiscount on QuoteLineItem  (after insert, after update) {

try {

List<OpportunityLineitem> OppItem = new List<OpportunityLineitem>();
Set<Id> ids = new Set<Id>();

    for(QuoteLineItem qItem: Trigger.new) {
    
    if(qItem.Product2 != null) {
    
    Ids.add(qItem.Product2Id);
    }
    }
     Map<id, OpportunityLineItem> OppliMap = new Map<id, OpportunityLineItem>([Select id, Total_Price_Discount__c from OpportunityLineItem Where Id in :Ids]);     
    
    for(QuoteLineItem qli : Trigger.new) { 
   // for(OpportunityLineItem Oppli : Trigger.new) {
  //  QuoteLineItem qli = qliMap.get(Oppli.Product2Id);
      OpportunityLineItem Oppli = OppliMap.get(qli.Product2Id);
    
   Oppli.Total_Price_Discount__c =   qli.Total_Price_with_Total_Discount_VAR__c;
    OppItem.add(Oppli);
    }
    update OppItem;
    }
    catch(Exception e){
   System.debug('ERROR: '+ e);
 }
}

Note: there can be multiple quotelineitems and same number at opportunity products.

 Appreciate quick help

Thanks,
G
Hi Everyone,

I have requirement based on the below conditions.

3 objects [Case, Contact, CustomObj]

Contact and CustomObj have lookup relationship.... and case is created based on contact.

My requirement is CustomObj appears as a related list in CONTACT record... I need bring that same CustomOBJ related list to CASE records whenever that particular CONTACT is added or CASE created on that CONTACT.... How can I achieve this.. I tried to edit layout but no luck it is not showing as related list instead appear in Extended lookup area...

Hi,

 I am new in Salesforce...I want to design a pop up window. The window will appear after save button is hit which will show the values those an user has entered as input. After the pop up comes out then the user will click the ok in pop up and the page will be redirected to the object view page.

 

Now how can I implement it throgh java script or any other possible way.

Can u pls provide some sample coding for it.

 

Thanks in advance,

hi guys,

how to attach a pdf file to 'notes & attachments' part of an object?

i was able to generate a pdf file using the visualforce with a custom controller.

then they ask to automatically generate and Attach the pdf file to the 'notes & attachment' as well when you press the custom 'buttons and links'.

all i can find is how to attach it to email.

can anyone help? thanks in advance.