• Lucian Mihai Ciobanu
  • NEWBIE
  • 35 Points
  • Member since 2016
  • Deutoria Force


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 8
    Replies
Hi,

Could you guys help me about this?
I'm newbie for programming.
I want to add value from my List to my custom fields which have sequential number as suffix of each field by using for loop.

Similar this..
Example
            My custom field API name : A_1__c,A_2__c,A_3__c

            List<User> userList = new List<User>();
            Integer counterXX = 1;
            for(User rUser : userList){
                xxx.A_counterXX__c = rUser.Id;
                counterXX++;
            }
Can I use this logic or what it should be? Please give me some advices.

Thank you.
Scenario :
I have an Account object and Schedule__c object.
I want to update account and Schedule__c objects' fields on update before trigger.
When I update Account in Batch class called by Account trigger I am getting following exception:
Update failed. CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY
When I remove update accoount; statement from the execute() function of batch class it is not reflecting the changes made in account object as it does automatically in Account trigger.

PLease let me know if anyone has the solution.

Thanks,
Sohel
Hi All;
I send a API call to a property base to change a field value of 'contact stage' to "EOI" .

Format :
{"prospect":{"token":"ffeba18d8aac8b5f2256f519fe063ff26443e311","contact":{"FirstName":"first name1","LastName":"LAST NAME","Email":"dumithu5@yahoo.com","MobilePhone":"7760304431","LeadSource":"WEB - IBN","Stage__c":"EOI","Postcode__c":"state","Buyer_Type__c":"First Home Buyer","State__c":"state 2"},"request":{"Description__c":"EOI\r\nReference code : Lt2uHTGK0wg, Comment : no comment","pba__City_pb__c":"ASFSEFSDFSDF SEF , suburb , state 2","Page_URL__c":"http://ibuynew.staging2-sl.netstarter.com.au/eoi/test3"}}}

When a new lead is sumitted to propertybase , new lead's  'contact stage' set to "EOI".
Some times, for new leads,  contact stage is set as "New Lead" automatically after API calls,  which is wrong

Can you help me  to find out the solution why 'contact stage' change time to time ? 


 
Hi all,

Can anyone help me to find a way to upload a file which larger in size>10mb im visualforce page.

Thanks in advance..
Hello everyone,

I have 1 custom object (Dimensions__c) which has a lookup relationship with Account standard object (Dimensions__c is Child).

There is a chechbox on Dimension__c (Repayment_Enabled__c).

Now wehenever i create a dimension this check box is made true automatically.

What my need is that, there should be only one check box true on for a record related to account.
Even though there may be 5 dimension records which are related to 1 account but checkbox should be true for only 1 dimension record. 

I have tried this one, But struck.
As i am new to development Please help me.


trigger paymentcheck on Account (before insert,before update,after insert) {
List<Account> acct = new List<Account>();
    List<Dimensions__c> vwo = new List<Dimensions__c>();   // my custom object
    for(Account a : trigger.new){
       if(Repayment_Enabled__c[0] == 'true'){   // this is the check box field which needs to be true for only one record related account
            Repayment_Enabled__c[1] = false;
        }
            }

}
How to solve this one.
 
  • June 01, 2016
  • Like
  • 0
Hi Guys
I am facing one challenge for long time .I have two object Account and Discount__c with lookup relationship ,Account object have a picklist filed with value LEAD and CUSTOMER.

Now i have created a account record with picklist value LEAD. my requirment is when i am going to create a record on discount__c object the picklist value which was LEAD is converted to CUSTOMER autometically.that mean the parent object which have have child record then it will happens.how to achieve this solution ?
 
Hi,

Could you guys help me about this?
I'm newbie for programming.
I want to add value from my List to my custom fields which have sequential number as suffix of each field by using for loop.

Similar this..
Example
            My custom field API name : A_1__c,A_2__c,A_3__c

            List<User> userList = new List<User>();
            Integer counterXX = 1;
            for(User rUser : userList){
                xxx.A_counterXX__c = rUser.Id;
                counterXX++;
            }
Can I use this logic or what it should be? Please give me some advices.

Thank you.
In the contact object i have a related list "Intralink Portal group" each contact can have multiple Intralink Porta groups. i have created a visual force page to add more than one intralink portal groups to a contact.now i want to select the Intralink Portal groups from one contact and add all of them to a new contact.how to do it? below is the visualforce page code and controller code.through controller i am able to add intralink portal groups to contact.but i am not able to copy all the list of intralink portal groups from one contact to another. below is the vf pageUser-added image
<apex:page Controller="ilGroupCtrl" doctype="html-5.0">
<apex:form >
    <apex:pageBlock title="Add Intralinks Groups">
        <apex:pageBlockButtons >
            <apex:commandButton action="{!save}" value="Save"/>
            <apex:commandButton action="{!Cancel}" value="Cancel"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection columns="1" id="main">
            <apex:inputField value="{!mainGroupLinker.Contact__c}" />

            <apex:pageBlockSectionItem >
                <apex:outputLabel value="Copy From" />
                <apex:inputField value="{!copyFrom.Contact__c}" required="false"/>
            </apex:pageBlockSectionItem>

            <apex:repeat value="{!groupList}" var="groupObj">
                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Intralinks Group" />
                <apex:inputField value="{!groupObj.Intralinks_Portal_Group__c}" required="false"/>
            </apex:pageBlockSectionItem>
            </apex:repeat>
            <apex:commandButton action="{!add}" value="Add" rerender="main"/>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>

Apex Controller
 
public class ilGroupCtrl {

Map<String, String> params;

public Intralinks_Group_and_Contact_Links__c mainGroupLinker { get; set; }
public Intralinks_Group_and_Contact_Links__c copyFrom { get; set; }
public List<Intralinks_Group_and_Contact_Links__c> groupList { get; set; }

public ilGroupCtrl() {
    params = ApexPages.currentPage().getParameters();
    mainGroupLinker = new Intralinks_Group_and_Contact_Links__c();
    copyFrom = new Intralinks_Group_and_Contact_Links__c();
    groupList = new List<Intralinks_Group_and_Contact_Links__c>();

    // if QueryString contains a contact Id, autofill the Contact field
    if(params.containsKey('cid')) {
        mainGroupLinker.Contact__c = params.get('cid');
    }

    groupList.add(mainGroupLinker);
}

public void add() {
    groupList.add(new Intralinks_Group_and_Contact_Links__c(Contact__c=mainGroupLinker.Contact__c));
    return;
}

public PageReference save() {
    List<Intralinks_Group_and_Contact_Links__c> toAdd = new List<Intralinks_Group_and_Contact_Links__c>();

    //query all the Groups the copyFrom contact has
    if(copyFrom.Contact__c != null) {
       List<Intralinks_Group_and_Contact_Links__c> toCopy = [SELECT Intralinks_Portal_Group__c FROM Intralinks_Group_and_Contact_Links__c where Contact__c = :copyFrom.Contact__c];

        for(Intralinks_Group_and_Contact_Links__c copyGroup : toCopy) {
            Intralinks_Group_and_Contact_Links__c newCopy = new Intralinks_Group_and_Contact_Links__c(Contact__c= mainGroupLinker.Contact__c,Intralinks_Portal_Group__c= copyGroup.Intralinks_Portal_Group__c);


        }

   }

    for (Intralinks_Group_and_Contact_Links__c g : groupList) {
        // save it if it's not null.
        if(g.Intralinks_Portal_Group__c != null) {
            toAdd.add(g);

        }
    }

    System.debug('toAdd count: ' + toAdd.size());
    if(toAdd.size() > 0) {

        insert toAdd;
    }

    return null;
}

  Public Pagereference Cancel(){
   Pagereference Page = new         PageReference(ApexPages.currentPage().getParameters().get('https://cs16.salesforce.com/{!mainGroupLinker.Contact__c}'));  
 return Page;
      }
   }

 
Please critique my code. I am very new at Apex and am not a programmer. 

The object of this code is to update the Opportunity Next Action field with the earliest associated activity. 

Maybe i could have put a join in the SOQL query but i am not confident with that yet. 
 
trigger TaskUpdateTrigger on Task (after insert, after update) {
  
    // When a task inserted/updated
   	For (Task t: Trigger.new){
        
       	// check if task is related to an opportunity
       	String relatedID = String.valueOf(t.whatId); 
        if(relatedID.substring(0,3)=='006'){
            
            // get all tasks associated with that opportunity
            Task[] relatedTasks = [SELECT Id, Subject, ActivityDate FROM Task 
                                   WHERE WhatId=:t.WhatId
                                   AND ActivityDate != null
                                   AND Status != 'Completed'
                                   ORDER BY ActivityDate ASC
                                   LIMIT 1];
            
            // get the related opportunity 
            Opportunity relatedOpp = [SELECT Id, NextStep FROM Opportunity
                                      WHERE Id =:t.WhatId];
            
            // format the string -date very short + next activity
            Datetime fullDateTime = relatedTasks[0].ActivityDate;
            String formatedDate = '[' + fullDateTime.format('d/M') + '] ';
            String NextStepString = String.valueOf(formatedDate + relatedTasks[0].Subject);
            
            // update Opportunity SObject
            relatedOpp.NextStep = NextStepString;
			// update database
            update relatedOpp;          
        }
    }  
}