• eworks123456
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 2
    Replies

 

Hello Team,
I want to share basic dml functionality on sales-force objects, I hope this will help you all. 
Regards,

 

Manoj Jain 

 

Page Code:
<apex:page controller="todayDML">
    <script type="text/javascript">
        function saveAlert()
        {
            alert("record has been saved successfully");
            setTimeout("location.reload(true);");
        }
        function deleteAlert()
        {
            alert("record has been deleted successfully");
            setTimeout("location.reload(true);");
        }
        function modifyAlert()
        {
            alert("record has been modified successfully");
            setTimeout("location.reload(true);");
        }
        function removeAllAlert()
        {
            alert("All record has been deleted successfully");
            setTimeout("location.reload(true);");
        }
        
       
    </script>
<apex:messages /> 
    <apex:form >
        <apex:panelGrid columns="2">
            Name: <apex:inputText value="{!dName}" />
            Last Name: <apex:inputText value="{!lName}"/>
            Summary: <apex:inputText value="{!sum}"/>
        </apex:panelGrid>
        <br/><br/>
        <apex:commandButton value="Save" action="{!save}"  oncomplete="saveAlert()" />
        <apex:commandButton value="Update" action="{!updateDml2}" oncomplete="modifyAlert();"/>
        <apex:commandButton value="Delete" action="{!delete1}" oncomplete="deleteAlert();"/>
        <apex:commandButton value="Remove All" action="{!removeAll}" oncomplete="removeAllAlert();"/>
        <apex:commandButton value="Search" action="{!doSearch}" rerender="block1" status="status"/>
        <apex:commandButton value="Reset" action="{!reset}"/><br/><br/>
    </apex:form>    
    <apex:form >
        <apex:pageBlock id="block1">
            <apex:actionStatus id="status" startText="requesting..."/>
                <apex:pageBlockTable value="{!dataDml}" var="da" rendered="{!NOT(ISNULL(dataDml))}">
                    <apex:column value="{!da.name}"/>
                    <apex:column value="{!da.Last_Name__c}"/>
                    <apex:column value="{!da.Other__c}"/>
                    <apex:column value="{!da.dml1__r.name}"/>
                    <apex:column value="{!da.dml1__r.Summary__c}"/>
                </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
        </apex:page>

Controller Code:

public class todayDML 
{
    public String dName{get; set;}
    public String lName{get; set;}
    public String sum{get; set;}
    public String valueOne{get; set;}
    
    public void save()
    {
        dml1__c d1 = new dml1__c(
            name = dName,
            Summary__c = sum
        );
        insert d1;
        
        dml2__c d2 = new dml2__c(
            name = dName,
            Last_Name__c = lName,
            Other__c = sum,
            dml1__c = d1.id
        );
        insert d2;
        //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Bill-To Sites successfully created'));

       
    }
    public void updateDml2()
    {
        List<dml2__c> d2 = [SELECT id,name, Last_Name__c, Other__c,dml1__c FROM dml2__c WHERE name =: dName];
        List<dml1__c> d1 = [SELECT Id, Summary__c FROM dml1__c];
        for(dml2__c dm2 : d2)
        {
            dm2.Last_Name__c = lName;
            dm2.Other__c = sum;
            for(dml1__c dm1 : d1)
            {
               if(dm1.Id == dm2.dml1__c)dm1.Summary__c = sum;
            }
        }
        update d2;
        update d1;
       
    }
    public void delete1()
    {
        dml1__c[] d1 = [select name from dml1__c where name =: dName limit 50];
        dml2__c[] d2 = [select name from dml2__c where name =: dName limit 50];
        try {
            delete d1;
            delete d2;} 
        catch (DmlException e){
            System.debug(e);}
            
    }
    
    public void removeAll()
    {
        dml1__c[] d1 = [select name from dml1__c];
        dml2__c[] d2 = [select name from dml2__c];
        try {
            delete d1;
            delete d2;} 
        catch (DmlException e){
            System.debug(e);}
            
    }
    
   List<dml2__c> dataDml;
    public List<dml2__c> getDataDml(){
        return dataDml;
    }
   public PageReference doSearch(){
        dataDml = [select name, Last_Name__c, Other__c,dml1__r.name, dml1__r.Summary__c from dml2__c where name =: dName];
        return null;
    }
    
    public void reset(){
        dName = '';
        lName = '';
        sum = '';
    }
    
}

 

 

 

Visual Force Page Code:
<apex:page controller="TestFieldPopulationController" id="pg">
    <script type="text/javascript">
        function userInput(){
            var UInput=document.getElementById("{!$Component.pg.frm.in}").value;
            return UInput;
        }
        
    </script>
    
    <apex:form id="frm">
        <apex:actionFunction name="hitMe" action="{!iWantMyJSValues}" rerender="jsvalues">
            <apex:param name="one" value="" />
            <apex:param name="two" value="" />
            <apex:param name="three" value="" />
        </apex:actionFunction>
        
        <apex:outputPanel id="jsvalues">
            <apex:panelGrid columns="2">
                Value One:<apex:inputText id="in" value="{!valueOne}" onclick="hitMe(userInput(),'{!email}','{!state}' )"/>
                Value Two:<apex:inputText value="{!valueTwo}" />   
                Value Three:<apex:inputText value="{!valueThree}" />
            </apex:panelGrid>        
        </apex:outputPanel>
   </apex:form>
</apex:page>


Controller Code:

public class TestFieldPopulationController 
{
    public String valueOne { get; set; }
    public String valueTwo { get; set; }
    public String valueThree { get; set;}
    public String email{ get; set;}
    public String state{ get; set;}
    
    public PageReference iWantMyJSValues() 
    {
        valueOne = Apexpages.currentPage().getParameters().get('one');
        valueTwo = Apexpages.currentPage().getParameters().get('two');
        valueThree = Apexpages.currentPage().getParameters().get('three');
        email = [select Email__c from Employee_Detail__c where name =:valueOne].Email__c;
        state = [select State__c from Employee_Detail__c where name =:valueOne].State__c;
        return null;
    }
}


 

Value OneHello Team,

 

 

I want to share field population functionality with community so that none of us invest more time on R & D  work.

Scenario  is:

 

1. There are three fields in my visual force page(Value One, Value Two, Value Three).

2. Now whenever user will put value on "Value One" field  and click on that the values of other two fields will automatically get populated.

 

 

Hope this will helpful for all of you.

 

Regards,

Manoj Jain

 

 

 

Hello Team

 

 

My scenerio is whenever end user will put value on field value one then automatically value should be populate in other two fields value two and employee name.

 

I have attached picture with this mail.

 

Please guide me.

 

Regards,

raju 

 

 

 

Hi All,

 

I have created 20 custom objects in salesforce.

Now i want to integrate these objects with flex.

I want to perform insert,update,delete,update operation from flex side which i have to integrate with salesforce via webservice.

 

My need is instead og writing apex webservice manually for 20 objects is there any way(some API method) which generate these apex web service classes automatically.

 

Please help me.

 

Regards,

Manoj Jain

Hi All,

 

I want to develop one application with the help of flex(as a frontend) and force.com database(as a backend).

I want to call flex application via force.com webservice.

So if someone have related document please share with me.

It would be really helpful for me because i am totally new in this field. 

 

Regards,

Manoj

Hello Team.

 

           My requirement is "i want to populate one text field value in visualforce page by selecting another field(by clicking on enter key) in the same page".

 

Scenario :

 

1. I have three text fields in my page Employee Id, Employee FName, Employee LName.

2. Whenever user will put Employee Id and press enter key  on that field(Employee Id) the related data should be populated on another two fields(Employee FName, Employee LName) .

 

Please guide me how can i achieve this functionality.

 

Thanks & regards,

Raju Deep

Hi,

how do I disable(gray out) a field or two based on a selected value of a picklist. in non-salesforce a javascript would help me in it.