Enabling customers to edit a selection of their own information in customer portal

A prospect asked about the possibility of letting their customers updating their own information (phone numbers, email address etc) via the customer portal. I am aware that today this functionality does not exist out of the box, so modifications to the customer portal files will have to be made:

  • a new page will have to be added displaying the customers information
  • a new page will have to be added for editing your information

But then is my question: would the best solution be our own forms with prefilled variables or should an HTML form be used? And if HTML form, how do I capture the submitted data?

RE: Enabling customers to edit a selection of their own information in customer portal

Hi Patrik,

I prefer working with HTML pages when building customer centres, and avoid using forms as it in my opinion has some limitations when it comes to how it works and looks.

Building a custom changeCust.html isn't that difficult, and your request could be done with just minor changes.

This is done in two parts:

Part 1: HTML element

You'll need the input elements, and a unique input name (e.g: <input name="email" type="text" />)

 

Part 2: CRMScript

Since the changeCust form action already points to the same page, all you'll need to have a CRMScript on that same page that updates the current customer if any changes has been done.

A short example would be to do something like this:

%EJSCRIPT_START%
<%

String savedEmail = getCgiVariable("email");
// If the email field contains a value
if(!savedEmail.isEmpty())
{
  // Check if the saved email is different from the current email address
}

%>
%EJSCRIPT_END%
<!-- HTML Elements -->
Af: Simen Mostuen Iversen 1. mar 2021

RE: Enabling customers to edit a selection of their own information in customer portal

How do you populate the HTML elements with data from SO? Am trying embedding some script for fetching the user's information and getting that displayed in input-elements but am not successful in doing so.

Af: Patrik Larsson 3. mar 2021

RE: Enabling customers to edit a selection of their own information in customer portal

There are several ways of doing this. What I usually do is a mix of CRMScript and Parser variables.

Example:

%EJSCRIPT_START%
<%

// Fetches the current main email address of the customer
String displayEmail = getParserVariable("customer.email");

// Fetches the value from the input field
String savedEmail = getCgiVariable("email");

// If the email field contains a value and is different than the current email address
if(!savedEmail.isEmpty() && savedEmail != displayEmail)
{
  String customerId = getParserVariable("customer.id");
  Bool setEmail = false;
  Customer c;

  // If Email is found in the system
  if(c.findFromEmail(savedEmail))
  {
    if(c.getValue("id") != customerId)
    {
      // Email already exists on a different custId
    }
    else
    {
      // Set the email as rank 1
      setEmail = true;
    }
  }
  else 
  {
    // Email address does not exist in the system, add it to the customer and set rank 1
    setEmail = true;
  }
  if(setEmail)
    displayEmail = savedEmail;
}
// Sets the parser variable 
setParserVariable("custEmail", displayEmail);

%>
%EJSCRIPT_END%
<form>
  <input name="email" value="%custEmail%" />
</form>

 

This is just an example - and the code should be tested before you publish anything

Af: Simen Mostuen Iversen 3. mar 2021

RE: Enabling customers to edit a selection of their own information in customer portal

Thanks for a great example! It explained it very well :)

Af: Patrik Larsson 3. mar 2021

RE: Enabling customers to edit a selection of their own information in customer portal

Any clue to why I am always logged out of the customer center when I click "Update" on the changeCust-page?

Af: Patrik Larsson 5. mar 2021

RE: Enabling customers to edit a selection of their own information in customer portal

Can you post the code?

What is the button name and form name?

Af: Simen Mostuen Iversen 5. mar 2021