• Rogerio Lara 2028
  • NEWBIE
  • 50 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 75
    Replies
I need to create a child record when a new parent record is created.

I am trying to create an Apex trigger that creates or forces a child record to be created when a new parent record is created, but unfortunately isn't working :-(

 
trigger CreateBuyingInfluence on Opportunity_Positioning__c (after insert)

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

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

       Childs.add(Child);      
    }

    insert Childs;
}

I'm getting this error message: Error: Compile Error: Expression cannot be assigned at line -1 column -1

Please, I would really appreciate any help. ;-)

Thank you,
Rog
Hi everyone,

I'm getting  -Error: Unknown property 'Opportunity_Positioning__cStandardController.Buying_Influence__c'? 

Any ideas what  I am doing wrong? Your assistance would be much appreciated!

Thank you,

Rog

<apex:page standardcontroller="Opportunity_Positioning__c">
           extensions="EditableBuyingInfluenceExtension"
<apex:sectionheader title="{!$ObjectType.Buying_Influence__c.label} Edit" subtitle="{!IF(ISNULL(Buying_Influence__c.Name), 'New Buying Influence',Buying_Influence__c.Name)}"/>
    <apex:form >
        <apex:pageblock mode="edit" title="{!$ObjectType.Buying_Influence__c.label} Edit">
            <apex:pageblockbuttons >
                <apex:commandbutton value="Save" action="{!Save}"/>
                <apex:commandbutton value="Cancel" action="{!Cancel}"/>
            </apex:pageblockbuttons>
            <apex:pageblocksection title="Information" showheader="true" columns="2">
                    <apex:outputText> value="{!Opportunity_Positioning__c.Name}"/>
                    <apex:outputText> value="{!Opportunity_Positioning__c.Opportunity__c}"/>
                    <apex:pageblocksectionitem />
            <apex:pageBlockSectionItem >
                <apex:pageblocksection id="childList" columns="1" title="Buying Influence" collapsible="false">
                <apex:variable var="rowNum" value="{!ZERO}" />
                <apex:outputLabel value="No Buying Influence currently exist. Click below to Add." rendered="{!NOT(hasChildren)}"/>
                    <apex:pageBlockTable value="{!children}" var="Buying Influence" rendered="{!hasChildren}">
                    <apex:column headerValue= "Buying Influence">
                    <apex:inputfield value="{!Buying_Influence__c.Name}" required="true"/>
                    <apex:column headerValue= "SCOP">
                    <apex:inputfield value="{!Buying_Influence__c.SCOP__c}" required="true"/>
                    <apex:column headerValue= "Influencer Name">
                    <apex:inputfield value="{!Buying_Influence__c.Influencer_Name__c}" required="true"/>
                    <apex:column headerValue= "Buying Influence role">
                    <apex:inputfield value="{!Buying_Influence__c.Buying_influence_role__c}" required="true"/>
                    <apex:column headerValue= "Degree of Influence">
                    <apex:inputfield value="{!Buying_Influence__c.Degree_of_Influence__c}" required="true"/>
                    <apex:pageblocksectionitem />
               </apex:column>
               <apex:pageblocksection title="How well is based covered for this contact" showheader="true" columns="2">
               </apex:pageblocksection>
               </apex:column> headerValue="Rating for base covered">
                    <apex:inputfield value="{!Buying_Influence__c.Rating_for_base_covered__c}" required="true"/>
               </apex:column> headerValue="Equivalent Collinson Stakeholder">
                    <apex:inputfield value="{!Buying_Influence__c.Equivalent_Collinson_Stakeholder__c}" required="false"/>
               </apex:column> headerValue="Evidence to support your rating">
                    <apex:inputfield value="{!Buying_Influence__c.Evidence_to_support_your_rating__c}" required="false"/>
                    </apex:column>
                    <apex:column headerValue=" ">
                    <!-- This is the second half of the trick to keep track
                    of your row index for deletion. -->
                    <apex:variable var="rowNum" value="{!rowNum + 1}" />
                    <apex:commandLink value="Delete" action="{!removeFromList}" rerender="childList,messages" immediate="true"> 
     <apex:param name="removeIndex" assignTo="{!removeIndex}" value="{!rowNum}" />
            </apex:commandLink>
          </apex:column>
        </apex:pageBlockTable>
        <apex:commandButton value="Add Buying Influence" action="{!addToList}" rerender="childList, messages" immediate="true" />
      </apex:pageBlockSection>
     </apex:pageblocksectionitem>
     </apex:outputtext> </apex:outputtext>
    </apex:pageblocksection>
</apex:pageblock>
</apex:form>
</apex:page>
Hi everyone,

I have 2 custom objects, 1) SCOP and 2)Buying Influence.
The 'SCOP' object is related to 'Opportunities', and the  'Buying Influence' object is related to SCOP.

Opportunity >SCOP > Buying Influence.

I was wondering if it would be possible to create a visualforce page that combines both 'SCOP' and 'Buying Influence' pages into one, so that when I create a new SCOP the Buying Influences are also created at the same time?

Does this make sense?

Thank you,

Rog
Hi developers,

I was wondering if anyone could save me today! Pleassseeee! ;-)

I have the following trigger and a validation rule that helps to enforce contact roles to be created for the opportunities depending on the sales stage and amount of the opportunity. This is working well.

------------------------------------------------------------------------------------------ This is what I have - FYI ---------------------------------------------------------------------------------

trigger updatecontactrolecount on Opportunity (before insert, before update)
{

Boolean isPrimary;
Integer iCount;

Map<String, Opportunity> oppty_con = new Map<String, Opportunity>();//check if the contact role is needed and add it to the oppty_con map
for (Integer i = 0; i < Trigger.new.size(); i++) 
{
        oppty_con.put(Trigger.new[i].id,
        Trigger.new[i]);      
}
isPrimary = False; 
for (List<OpportunityContactRole> oppcntctrle :[select OpportunityId from OpportunityContactRole where (OpportunityContactRole.IsPrimary = True and OpportunityContactRole.OpportunityId in :oppty_con.keySet())])
{
 if (oppcntctrle .Size() >0)
 {
 isPrimary = True;     
 }
}
iCount = 0;
for (List<OpportunityContactRole> oppcntctrle2 : [select OpportunityId from OpportunityContactRole where (OpportunityContactRole.OpportunityId in :oppty_con.keySet())])//Query for Contact Roles
{    
 if (oppcntctrle2 .Size()>0)
 {
 iCount= oppcntctrle2 .Size();     
 }
}
for (Opportunity Oppty : system.trigger.new) //Check if  roles exist in the map or contact role isn't required 
{
Oppty.Number_of_Contacts_Roles_Assigned__c = iCount;
Oppty.Primary_Contact_Assigned__c =isPrimary; 
}
}

Validation rule: 
AND(OR(ISPICKVAL(StageName, 'Advanced Proposal'), ISPICKVAL (StageName, 'Final Negotiation'), ISPICKVAL (StageName, 'Contract Signed')),  Number_of_Contacts_Roles_Assigned__c <2,  Amount  >= 1000000)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Now this is what I need:

Standard Object = Opportunity
Custom Object = Strategic Client Opportunity Plan

I created a read only checkbox field on the opportunity = Has_Strategic_Client_Opportunity_Plan__c and left it unchecked

I want the trigger to check the "Has_Strategic_Client_Opportunity_Plan__c" when a new Strategic Client Opportunity Plan is created. 

Then I will create a validation rule on the opportunity to check whether this field is checked and the other required values too.

Does this make sense?

Your help is really appreciated. ;-)

Thank you,

Rog
Hi developers out there! I need help please;-)

My manager's requests are coming faster than my time to learn visualforce, and I am slowly making progress (more like a snail).

Well, I've built 2 custom objects that are related to each other (parent and child). I need the existing related list (child) to be added as a component in the Parent object layout, so that when I am editing the parent record page, I will, at the same time, be able to view and edit the child as well.

Parent: Strategic Client Opportunity Plan 
Child: Buying Influence

objects

I would appreciate any guidance that will help me develop this visualforce. I know that is possible, because I have seen it, but I don't where to start. I am stuck. :-(

Thank you,

Rog
Hi there, please help! I have a short sales questionnaire in excel at the moment that contains 1) question - yes/no and date of assessment. I need to somehow develop this form in Salesforce and have it embeded in a particular custom object so that sales rep can complete it as part of the data input. Any Visualforce page I can work with? Really appreciate any feedback. Thank you. Rog
Hi there,

I was wondering if anyone has ever tried or heard about creating assessment questions on the opportunity record either as "long" text fields or a related list. The stand field types can only hold a certain number of characters, and need to create a sort of form on the opportunity to help the sales reps position their deals. I've tried surveys and forms, but it's to cumbersome to work with and it doesn't give me the desired look and feel either.
Thank you,
Rog
Hi there,

I was wondering if anyone could help, please!!!

I am trying to create a field update that will update a text field with the data from another picklist field and the created date field.

For the picklist field I originally had TEXT (picklistfield_name), but I was not able to add the DATEVALUE Created Date.

Any idea of how this can be achieved?

Thank you,

Rog
 
Hello again, I was wondering what is the best way to copy the opportunity name in another formula text field based on the stage picklist field?

The formula text field will be only visible to administrators and this field is only to be used for specific report.

IF(ISPICKLIST(StageName, 'Prospecting', ........ ) I don't know how to finish this

Thank you,

Rog
Hi there,  I have a new custom object Opportunity Positioning, that is related to the Opportunity object.

I need the field  "Opportunity Positioning" which is a name field when the object was created,  to be populated with a default value "Autofill" at insert.

I've tried to override the New button on the  Opportunity Positioning related list to the Opportunity, and it works, however the relation between the Opportunity and the Opportunity Positioning objects disappears and it has be manually selected again.

<apex:page standardController="Opportunity_Positioning__c" action="{!URLFOR($Action.Opportunity_Positioning__c.New, null, ['Name'='Autofill'], true)}" />

Any ideas how I can retain the relationship between objects when creating a new record and at the same time update the Opportunity Positing field? Thank you.
Hi there, Please Help! ;-)

I have a checkbox field that is by default checked when a record is created. (Good)

Let's suppose I have a custom object that relates to the Opportunity object, then I create record1 under the Opportunity (related list).

When I then create record2, I need the check box on record1 to be automatically unchecked.

Please can someone help me with the trigger. I don't really even know where to start ;-(

Thank you,

Rog
I need to create a child record when a new parent record is created.

I am trying to create an Apex trigger that creates or forces a child record to be created when a new parent record is created, but unfortunately isn't working :-(

 
trigger CreateBuyingInfluence on Opportunity_Positioning__c (after insert)

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

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

       Childs.add(Child);      
    }

    insert Childs;
}

I'm getting this error message: Error: Compile Error: Expression cannot be assigned at line -1 column -1

Please, I would really appreciate any help. ;-)

Thank you,
Rog
Hi developers,

I was wondering if anyone could save me today! Pleassseeee! ;-)

I have the following trigger and a validation rule that helps to enforce contact roles to be created for the opportunities depending on the sales stage and amount of the opportunity. This is working well.

------------------------------------------------------------------------------------------ This is what I have - FYI ---------------------------------------------------------------------------------

trigger updatecontactrolecount on Opportunity (before insert, before update)
{

Boolean isPrimary;
Integer iCount;

Map<String, Opportunity> oppty_con = new Map<String, Opportunity>();//check if the contact role is needed and add it to the oppty_con map
for (Integer i = 0; i < Trigger.new.size(); i++) 
{
        oppty_con.put(Trigger.new[i].id,
        Trigger.new[i]);      
}
isPrimary = False; 
for (List<OpportunityContactRole> oppcntctrle :[select OpportunityId from OpportunityContactRole where (OpportunityContactRole.IsPrimary = True and OpportunityContactRole.OpportunityId in :oppty_con.keySet())])
{
 if (oppcntctrle .Size() >0)
 {
 isPrimary = True;     
 }
}
iCount = 0;
for (List<OpportunityContactRole> oppcntctrle2 : [select OpportunityId from OpportunityContactRole where (OpportunityContactRole.OpportunityId in :oppty_con.keySet())])//Query for Contact Roles
{    
 if (oppcntctrle2 .Size()>0)
 {
 iCount= oppcntctrle2 .Size();     
 }
}
for (Opportunity Oppty : system.trigger.new) //Check if  roles exist in the map or contact role isn't required 
{
Oppty.Number_of_Contacts_Roles_Assigned__c = iCount;
Oppty.Primary_Contact_Assigned__c =isPrimary; 
}
}

Validation rule: 
AND(OR(ISPICKVAL(StageName, 'Advanced Proposal'), ISPICKVAL (StageName, 'Final Negotiation'), ISPICKVAL (StageName, 'Contract Signed')),  Number_of_Contacts_Roles_Assigned__c <2,  Amount  >= 1000000)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Now this is what I need:

Standard Object = Opportunity
Custom Object = Strategic Client Opportunity Plan

I created a read only checkbox field on the opportunity = Has_Strategic_Client_Opportunity_Plan__c and left it unchecked

I want the trigger to check the "Has_Strategic_Client_Opportunity_Plan__c" when a new Strategic Client Opportunity Plan is created. 

Then I will create a validation rule on the opportunity to check whether this field is checked and the other required values too.

Does this make sense?

Your help is really appreciated. ;-)

Thank you,

Rog
Hi guys, please help me how we can show pop up messages after performing DML operations insert,update,etc in salesforce