• Sakthi169
  • NEWBIE
  • 20 Points
  • Member since 2016

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

I am create the form for refer more people and the referr get some points. i create the form but i face the problem how to push the data into salesforce. 
1. 1st i need check the referr no is exist or not, No means put error message.
2. Check the mobile no(Referral) already exist or not. Exist means there is no use of reference. Then put error message like "user is already exist".
3. How to push the form data into salesforce.

My code is 
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
</head>
<body>
<div class ="container">
   <p>Name:
        <input type="text" name="Name" />
    </p>
    <p>Email:
        <input type="text" name="player_email" />
    </p>
      <p>Mobile:
        <input type="text" name="mobile" />
    </p>
     <p> Refer:

<div id="selected_form_code">
 <select id="select_btn">
 <option value="0">--Select--</option>
 <option value="1">One</option>
 <option value="2">Two</option>
 <option value="3">Three</option>
 <option value="4">Four</option>
 <option value="5">Five</option>
 </select>
 </div>

	<div id="form1">	
		<form id="form_submit" action="#" method="post">
		 <!-- dynamic Registration Form Fields Creates here-->
		</form>
	</div> 
<!------ right side advertisement div ----------------->

	
</div>


<script type="text/javascript">
$(document).ready(function(){

	 $('select#select_btn').change(function(){
	
    var sel_value = $('option:selected').val();
	if(sel_value==0)
	{
		//Resetting Form 
		$("#form_submit").empty();
		$("#form1").css({'display':'none'});
	}
	else{
		//Resetting Form 
		$("#form_submit").empty();
		
		//Below Function Creates Input Fields Dynamically 
	    create(sel_value);
		
		//appending submit button to form
		$("#form_submit").append(
		$("<input/>",{type:'submit', value:'Sumbit'})
		)
		}	
	});	
	
function create(sel_value){
   for(var i=1;i<=sel_value;i++)   
	   {
	   $("div#form1").slideDown('slow');
	   
	    $("div#form1").append(
		$("#form_submit").append(
		$("<div/>",{id:'head'}).append(
		$("<h3/>").text("Refer Form"+i)),
    $("<h7/>").text("Name: "),
		$("<input/>",  {type:'text', placeholder:'Name', name:'name_'+i}),
		$("<br/>"),
    	$("<br/>"),
     $("<h7/>").text("Mobile No: "),
		$("<input/>", {type:'text', placeholder:'Mobile', name:'mobile'+i}),
		$("<br/>"),
    	$("<br/>"),
         $("<h7/>").text("Email: "),
		$("<input/>", {type:'email', placeholder:'Email', name:'email_'+i}),
		$("<br/>"),
    	$("<br/>"),
     $("<h7/>").text("City: "),
    $("<select>").append('<option val="0">--Select--</option>','<option val="1">One</option>','<option val="2">Two</option>','<option val="3">Three</option>','<option val="4">Four</option>','<option val="5">Five</option>'),
	$("<br/>"),
  	$("<br/>"),
   $("<h7/>").text("Course: "),
    $("<select>").append('<option val="0">--Select--</option>','<option val="1">One</option>','<option val="2">Two</option>','<option val="3">Three</option>','<option val="4">Four</option>','<option val="5">Five</option>'),
		$("<hr/>"),
		$("<br/>")
	                 ))
	    }
	
	}
  
	
	
});
</script>
</body>

How to push the data ????
Hi i am new to salesforce and i create the form with multiple form field.
For example add more customer. 
I have the form details like customer name in 1st row.
then drop down add more as drop down list and then (eg 2 means it shows two form field like 1st row).
i need to update the refer field with 1st row customer name and i need check the add more customer mobile no is already exist or not.
Hi,

I need to prevent the form value re-submit on refresh(reload the page). I create page with validation , now i facing the problem once submit the i display the success message.When i refresh or reload the page it re-submit the page again(i put the validation duplicate check for mobile) and it shows the Error Message. How to reload the page without re-submit the form value. My code is 
<?php
// session_start() has to go right at the top, before any output!
session_start();
?>
<?php
  
	$username="xxxxxx";
	$pwd="xxxxxx";
	$st="xxxxxxxxx";
    $i=0;
	try{
		
            require_once ('soapclient/SforcePartnerClient.php');
            require_once ('soapclient/SforceEnterpriseClient.php');

		$mySforceConnection =new SforceEnterpriseClient();
		$mySforceConnection->createConnection("soapclient/enterprise.wsdl.xml");
		$mySforceConnection->setEndpoint('https://test.salesforce.com/services/Soap/c/36.0/0DFO000000001Oi');
		$mySforceConnection->login($username, $pwd.$st);
		//Checking no exception is thrown
		$i=1;
	}	
	catch(Exception $e){
		echo $e;
	}
    
    // On Click of the insert button
	if(@$_REQUEST['OK']) {

    //First check for validation
	if($_REQUEST['name'] == null || $_REQUEST['name'] == '') {
		echo "First Name can't be blank";	
	} else if($_REQUEST['lastName'] == null || $_REQUEST['lastName'] == '') {
		echo "Last Name can't be blank";	
	} else if($_REQUEST['mobNo'] == null || $_REQUEST['mobNo'] == '') {
		echo "Mobile Number can't be blank";	
	} else if($_REQUEST['email'] == null || $_REQUEST['email'] == '') {
		echo "Email can't be blank";	
	}else {
		// Checking no exception is iccured during login
		if($i==1) {
			 try {
			 	// Checking whether Phone number exists in salesforce or not?
				$query = "SELECT Id,LastName from Account where PersonMobilePhone='".$_REQUEST['mobNo']."'";
				$response = $mySforceConnection->query($query);
				$count=0;
				foreach ($response->records as $record) {
					$count++;
					break;
				}
				// if count is greater than 0, this means phone alredy exists
				if($count > 0) {
					echo "Mobile Number already exists";
				} else {
					$records = array();

                $records[0] = new stdclass();
                $records[0]->FirstName = $_REQUEST['name'];
                $records[0]->LastName = $_REQUEST['lastName'];
                $records[0]->PersonMobilePhone = $_REQUEST['mobNo'];
				$records[0]->CustomLandLine__c = '';
				$records[0]->City__c = 'Mumbai';
				$records[0]->Source__c = 'Database';
					$records[0]->OwnerId = '00590000002QqfJ';
					 $response = $mySforceConnection->create($records, 'Account');
					 echo '<div style=" background:#00FF00;height:25px;><font size="4"><center><b>'."Lead Inserted Successfully".'</b>  
												 </center></font></div>';
												 
				}

			 } catch(Exception $e){
			 	echo $e;
			 }	

		} else {
			echo "Wrong UserName, password or Security Token.";
	    }
	}
			 
}
?>
<html>
<title>
SalesForce - PHP Integration
</title>
<body bgcolor="#CCFFFF">

<form name="form3" method="post">
<div style="background:#9999FF; color:#000000; height:30px; vertical-align:middle; font-size:22px; font-weight:bold"><center> Insert Lead</center></div><br />
<table align="center">      <tr>
                      <td><b>First Name</b></td>
                      <td><input type="text" name="name" id="name" size="25"></td>
                   </tr>
				   <tr>
                      <td><b>Last Name</b></td>
                      <td><input type="text" name="lastName" id="lastName" size="25"></td>
                   </tr>
                   <tr>
                      <td><b>Mobile No.</b></td>
                      <td><input type="text" name="mobNo" id="mobNo" size="25"></td>
                   </tr>
				   <tr>
                      <td><b>Email</b></td>
                      <td><input type="text" name="email" id="email" size="25"></td>
                   </tr>
                   	<tr>
                      <td colspan="2"><center><input type="submit" value="Insert" name="OK"></center></td>
                  </tr>
				  
</table>
</form>
</body>
</html>

How to do it????
Hi 

I create the form with mandatory field(Name,Mobile,city,Email,Gender).I create the form and insert the value into salesforce also.
But i need to throw the error message if mobile no is exist in salesforce and cannot submit without change the mobile no.
How can i do this anyone help????
Hi,

I am create the simple page with mandatory field(Firstname,Lastname,email,city,mobileno,source) once i submit form and it directly insert into salesforce. My code for ur reference
<?php
// session_start() has to go right at the top, before any output!
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
<?php
require_once ('soapclient/SforceEnterpriseClient.php');
define("USERNAME", "xxxxxxx");
define("PASSWORD", "xxxxxx");
define("SECURITY_TOKEN", "xxxxxxx");
$mySforceConnection = new SforceEnterpriseClient();
$wsdl = 'soapclient/enterprise.wsdl.xml';
$mySforceConnection->createConnection($wsdl);
$mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);
$mySforceConnection->setEndpoint('https://test.salesforce.com/services/Soap/c/30.0');
$LastName=$_POST["name"];
$CustomMobile__c=$_POST["mobileno"];
$query = "insert into 'Account'(LastName,CustomMobile__c )VALUES('$LastName','$CustomMobile__c')";
$result = $mySforceConnection->query($query);
print_r($result);

			$nameErr = $emailErr = $genderErr = $mobilenoErr = $websiteErr = "";
$name = $email = $gender = $comment = $mobileno = $website = "";

if ($_POST['submit']) {
   if (empty($_POST["name"])) {
     $nameErr = "Name is required";
   } else {
     $name = test_input($_POST["name"]);
     // check if name only contains letters and whitespace
     if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
       $nameErr = "Only letters and white space allowed"; 
     }
   }
  if (empty($_POST["mobileno"])) {
     $mobileno= "";
   } else {
     $mobileno= test_input($_POST["mobileno"]);
     // check if URL address syntax is valid (this regular expression also allows dashes in the URL)
     if (!preg_match("/^[1-9][0-9]*$/",$mobileno)) {
       $mobilenoErr = "Invalid mobileno"; 
     }
   }

   if (empty($_POST["email"])) {
     $emailErr = "Email is required";
   } else {
     $email = test_input($_POST["email"]);
     // check if e-mail address is well-formed
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
       $emailErr = "Invalid email format"; 
     }
   }

   if (empty($_POST["website"])) {
     $website = "";
   } else {
     $website = test_input($_POST["website"]);
     // check if URL address syntax is valid (this regular expression also allows dashes in the URL)
     if (!preg_match("/b(?:(?:https?|ftp)://|www.)[-a-z0-9+&@#/%?=~_|!:,.;]*[-a-z0-9+&@#/%=~_|]/i",$website)) {
       $websiteErr = "Invalid URL"; 
     }
   }

   if (empty($_POST["comment"])) {
     $comment = "";
   } else {
     $comment = test_input($_POST["comment"]);
   }

   if (empty($_POST["gender"])) {
     $genderErr = "Gender is required";
   } else {
     $gender = test_input($_POST["gender"]);
   }
}

function test_input($data) {
   $data = trim($data);
   $data = stripslashes($data);
   $data = htmlspecialchars($data);
   return $data;
}
?>
<h2>Account Details</h2>
<p><span class="error">* required field.</span></p>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> 
   Name: <input type="text" name="name" value="<?php echo $name;?>">
   <span class="error">* <?php echo $nameErr;?></span>
   <br><br>
Mobile No: <input type="text" name="mobileno" value="<?php echo $mobileno;?>">
   <span class="error">* <?php echo $mobilenoErr;?></span>
   <br><br>
   E-mail: <input type="text" name="email" value="<?php echo $email;?>">
   <span class="error">* <?php echo $emailErr;?></span>
   <br><br>
 
  
   <br><br>
   Gender:
   <input type="radio" name="gender" <?php if (isset($gender) && $gender=="female") echo "checked";?>  value="female">Female
   <input type="radio" name="gender" <?php if (isset($gender) && $gender=="male") echo "checked";?>  value="male">Male
   <span class="error">* <?php echo $genderErr;?></span>
   <br><br>
   <input type="submit" name="submit" value="Submit"> 
</form>

<?php
echo "<h2>Your Input:</h2>";
echo $name;
echo "<br>";
echo $mobileno;
echo "<br>";
echo $email;
echo "<br>";
echo $website;
echo "<br>";
echo $comment;
echo "<br>";
echo $gender;
?>

Fatal error: Uncaught SoapFault exception: [soapenv:Client] No operation available for request {urn:enterprise.soap.sforce.com}login in C:\xampp\htdocs\soapclient\SforceBaseClient.php:169 Stack trace: #0 C:\xampp\htdocs\soapclient\SforceBaseClient.php(169): SoapClient->__call('login', Array) #1 C:\xampp\htdocs\soapclient\SforceBaseClient.php(169): SoapClient->login(Array) #2 C:\xampp\htdocs\test2.php(20): SforceBaseClient->login('xxxxxxx...') #3 {main} thrown in C:\xampp\htdocs\soapclient\SforceBaseClient.php on line 169
Hi to all,

I create the basic form with account fields and i need to upload the form values dirctly to salesforce.
<!DOCTYPE html>
<html>
<head>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">


<body>
<form method="POST">



<label for="first_name">First Name</label><input  id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br>

<label for="last_name">Last Name</label><input  id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br>

<label for="email">Email</label><input  id="email" maxlength="80" name="email" size="20" type="text" /><br>

<label for="company">Company</label><input  id="company" maxlength="40" name="company" size="20" type="text" /><br>

<label for="city">City</label><input  id="city" maxlength="40" name="city" size="20" type="text" /><br>

<label for="state">State/Province</label><input  id="state" maxlength="20" name="state" size="20" type="text" /><br>

<input type="submit" name="submit">

</form>
</head>
</body>
</html>

Hi,

I need to create the link and when i click the link it open the form in 

Account page. My form is 

<apex:page standardcontroller="Account" tabstyle="Account" extensions="MyExtension" >
 
 <apex:form >
 
 <apex:sectionheader title="Account Details" subtitle="{!if(Account.Id==null,'New Account',Account.Name)}"></apex:sectionheader>
<apex:pageblock mode="edit" id="leadPB" title="Account Edit">
 
 <apex:pageblockbuttons >
<apex:commandbutton action="{!save}" value="Save"></apex:commandbutton>
 <!-- If you wish to implement Save & New functionality you will have to write an Apex Extension with your own Save & New Method -->
 <apex:commandbutton action="{!cancel}" value="Cancel"></apex:commandbutton>
 </apex:pageblockbuttons>
 
        <apex:pageBlockSection >
     
        
            <apex:inputtext value="{!Account.LastName}" label="Customer Name"/>
            <apex:inputtext value="{!Account.PersonMobilePhone}"/>
            <apex:inputtext value="{!Account.CustomLandLine__c}"/>
            <apex:inputField value="{!Account.City__c}"/>
            <apex:inputField value="{!Account.PersonEmail}"/>
             <apex:inputField value="{!Account.Source__c}"/>
            
            <!-- <apex:commandButton action="{!save}" value="Save!"/>-->
        </apex:pageBlockSection>
    </apex:pageBlock>
<apex:pageMessages />
</apex:form>



</apex:page>
how to create link for this page????
Hi 
i am new to salesforce i create the page using visualforce.

<apex:page standardcontroller="Account" tabstyle="Account">
 
 <apex:form >
 
 <apex:sectionheader title="Account Details" subtitle="{!if(Account.Id==null,'New Account',Account.Name)}"></apex:sectionheader>
<apex:pageblock mode="edit" id="leadPB" title="Account Edit">
 
 <apex:pageblockbuttons >
 <apex:commandbutton action="{!save}" value="Save"></apex:commandbutton>
 <!-- If you wish to implement Save & New functionality you will have to write an Apex Extension with your own Save & New Method -->
 <apex:commandbutton action="{!cancel}" value="Cancel"></apex:commandbutton>
 </apex:pageblockbuttons>
 
        <apex:pageBlockSection >
     
        
            <apex:inputtext value="{!Account.LastName}" label="Customer Name"/>
            <apex:inputtext value="{!Account.PersonMobilePhone}"/>
            <apex:inputtext value="{!Account.CustomLandLine__c}"/>
            <apex:inputField value="{!Account.City__c}"/>
            <apex:inputField value="{!Account.PersonEmail}"/>
             <apex:inputField value="{!Account.Source__c}"/>
             <!-- <apex:commandButton action="{!save}" value="Save!"/>-->
        </apex:pageBlockSection>
    </apex:pageBlock>
<apex:pageMessages />
</apex:form>

after save the page i need update the account owner name is "Umadevi". how to do it??? If any way is there
 
I need to update owner(Standard Field) name on custom page(Buyer) using Referral Id(mobile of Lead owner)..
The Referral Id(Mobile No) already present in user details.
For example the buyer is created by me but i put the Referral Id was my manager mobile no.After created the Buyer i need to updated owner as my manager name not mine.Now it show my name.I don't want trigger without trigger,if there is any another way is possible???
Hi to all,

I am new to salesforce,i dont know how to write apex class for trigger.when i click the deploy i will get the following error.
Your organization's code coverage is 2%. You need at least 75% coverage to complete this deployment. Also, the following triggers have 0% code coverage. Each trigger must have at least 1% code coverage.
This is my trigger
trigger LeadAssignmentTrigger on Broker__c (before insert,before update) 
    {
       List<Broker__c > leadsToUpdate = new List<Broker__c >();
        for (Broker__c broker: Trigger.new)
        {     
            if (broker.Referral_ID__c!= NULL)
            {
                String str = broker.Referral_ID__c;
                Integer ln = str.Length();
                String likeStr = '%'+str.subString(ln-10, ln-7)+'%'+str.subString(ln-7, ln-4) +'%'+ str.subString(ln-4);

                // Find the sales rep for the current zip code
                List<User> zip = [select Id from User
                                       where MobilePhone Like : likeStr];

                // if you found one
                if (zip.size() > 0) 
                {    
                    //assign the lead owner to the zip code owner
                    broker.OwnerId = zip[0].Id; 
                    leadsToUpdate.add(broker);
                }
               else
                {
                    // Throw Error
                    broker.addError('Invalid Referrel ID');
                }
            } 
        }
     }
I am new to salesforce.Anyone help me to how to write apex class(test class) for above trigger.
 
I need to update owner(Standard Field) name on custom page(Buyer) using Referral Id(mobile of Lead owner)..
The Referral Id(Mobile No) already present in user details.
For example the buyer is created by me but i put the Referral Id was my manager mobile no.After created the Buyer i need to updated owner as my manager name not mine.Now it show my name.I don't want trigger without trigger,if there is any another way is possible???
Hi 

I create the form with mandatory field(Name,Mobile,city,Email,Gender).I create the form and insert the value into salesforce also.
But i need to throw the error message if mobile no is exist in salesforce and cannot submit without change the mobile no.
How can i do this anyone help????
Hi to all,

I create the basic form with account fields and i need to upload the form values dirctly to salesforce.
<!DOCTYPE html>
<html>
<head>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">


<body>
<form method="POST">



<label for="first_name">First Name</label><input  id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br>

<label for="last_name">Last Name</label><input  id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br>

<label for="email">Email</label><input  id="email" maxlength="80" name="email" size="20" type="text" /><br>

<label for="company">Company</label><input  id="company" maxlength="40" name="company" size="20" type="text" /><br>

<label for="city">City</label><input  id="city" maxlength="40" name="city" size="20" type="text" /><br>

<label for="state">State/Province</label><input  id="state" maxlength="20" name="state" size="20" type="text" /><br>

<input type="submit" name="submit">

</form>
</head>
</body>
</html>

Hi,

I need to create the link and when i click the link it open the form in 

Account page. My form is 

<apex:page standardcontroller="Account" tabstyle="Account" extensions="MyExtension" >
 
 <apex:form >
 
 <apex:sectionheader title="Account Details" subtitle="{!if(Account.Id==null,'New Account',Account.Name)}"></apex:sectionheader>
<apex:pageblock mode="edit" id="leadPB" title="Account Edit">
 
 <apex:pageblockbuttons >
<apex:commandbutton action="{!save}" value="Save"></apex:commandbutton>
 <!-- If you wish to implement Save & New functionality you will have to write an Apex Extension with your own Save & New Method -->
 <apex:commandbutton action="{!cancel}" value="Cancel"></apex:commandbutton>
 </apex:pageblockbuttons>
 
        <apex:pageBlockSection >
     
        
            <apex:inputtext value="{!Account.LastName}" label="Customer Name"/>
            <apex:inputtext value="{!Account.PersonMobilePhone}"/>
            <apex:inputtext value="{!Account.CustomLandLine__c}"/>
            <apex:inputField value="{!Account.City__c}"/>
            <apex:inputField value="{!Account.PersonEmail}"/>
             <apex:inputField value="{!Account.Source__c}"/>
            
            <!-- <apex:commandButton action="{!save}" value="Save!"/>-->
        </apex:pageBlockSection>
    </apex:pageBlock>
<apex:pageMessages />
</apex:form>



</apex:page>
how to create link for this page????
Hi 
i am new to salesforce i create the page using visualforce.

<apex:page standardcontroller="Account" tabstyle="Account">
 
 <apex:form >
 
 <apex:sectionheader title="Account Details" subtitle="{!if(Account.Id==null,'New Account',Account.Name)}"></apex:sectionheader>
<apex:pageblock mode="edit" id="leadPB" title="Account Edit">
 
 <apex:pageblockbuttons >
 <apex:commandbutton action="{!save}" value="Save"></apex:commandbutton>
 <!-- If you wish to implement Save & New functionality you will have to write an Apex Extension with your own Save & New Method -->
 <apex:commandbutton action="{!cancel}" value="Cancel"></apex:commandbutton>
 </apex:pageblockbuttons>
 
        <apex:pageBlockSection >
     
        
            <apex:inputtext value="{!Account.LastName}" label="Customer Name"/>
            <apex:inputtext value="{!Account.PersonMobilePhone}"/>
            <apex:inputtext value="{!Account.CustomLandLine__c}"/>
            <apex:inputField value="{!Account.City__c}"/>
            <apex:inputField value="{!Account.PersonEmail}"/>
             <apex:inputField value="{!Account.Source__c}"/>
             <!-- <apex:commandButton action="{!save}" value="Save!"/>-->
        </apex:pageBlockSection>
    </apex:pageBlock>
<apex:pageMessages />
</apex:form>

after save the page i need update the account owner name is "Umadevi". how to do it??? If any way is there
 
I need to update owner(Standard Field) name on custom page(Buyer) using Referral Id(mobile of Lead owner)..
The Referral Id(Mobile No) already present in user details.
For example the buyer is created by me but i put the Referral Id was my manager mobile no.After created the Buyer i need to updated owner as my manager name not mine.Now it show my name.I don't want trigger without trigger,if there is any another way is possible???