• Elavarasan Balasubramaniyan
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 0
    Replies
Hi all,
 
 
          I have code Logic in AMPScript Code:
%%[/* Modify to view AMPScript <div style="display:none"> */
VAR @email, @Split1, @Split2, @Split3, @acts, @acts2, @acts3
SET @rowset = LookupRows("raviDE","Email", "aomemail@gmail.com")
SET @row = Row(@rowset, 1)
set @email = "aomemail@gmail.com"
if rowcount(@rowset) > 0 then 
  set @email = Field(@row, "Email")
endif
set @act = Field(@row,"subscrption")
SET @Rows = BuildRowSetFromString(@act, ",")
set @rowCount = rowcount(@rows) 
output(concat("<br>@rowCount: ", @rowCount))
set @split1 = ""
set @split2 = ""
set @split3 = ""
set @acts = ""
set @acts2 = ""
set @acts3 = ""
if @rowCount > 0 then
  if @rowCount >= 1 then
    SET @Split1 = Field(Row(@Rows, 1), 1)
  endif 
  if @rowCount >= 2 then
    SET @Split2 = Field(Row(@Rows, 2), 1)
  endif 
  if @rowCount >= 3 then
    SET @Split3 = Field(Row(@Rows, 3), 1)
  endif 
  if @Split1 == "Seasonal travel information and trip ideas"  then
      SET @acts= "checked" 
  endif
  if @Split1 == "Travel Deals-monthly"  then
      SET @acts1= "checked" 
  endif
if @Split1 == "Ski Deals Seasonal"  then
      SET@acts2 = "checked" 
  endif
 if @Split2 == "Seasonal travel information and trip ideas"  then
      SET @acts= "checked" 
  endif
  if @Split2 == "Travel Deals-monthly"  then
      SET @acts1= "checked" 
  endif
if @Split2 == "Ski Deals Seasonal"  then
      SET @acts2= "checked" 
  endif
 if @Split3 == "Seasonal travel information and trip ideas"  then
      SET @acts= "checked" 
  endif
  if @Split3 == "Travel Deals-monthly"  then
      SET @acts1= "checked" 
  endif
  if @Split3 == "Ski Deals Seasonal"  then
      SET @acts2= "checked" 
  endif
endif
/*</div>*/
]%%
<br>%%=v(@Split1)=%%
<br>%%=v(@Split2)=%%
<br>%%=v(@Split3)=%%
<form id="myForm" method="post" action="http://pages.S7.exacttarget.com/page.aspx?QS=38dfbe491fab00ea0ad4b925273e8608d40bab6a35b96d3428a16f6a0f519dc7">
<br>Email: <input type="text" name="test4" value="%%=v(@email)=%%" />
<br>Checkbox:<input type="checkbox" name="test5" value="Seasonal travel information and trip ideas"  %%=v(@acts)=%%/> Seasonal travel information and trip ideas
<br><input type="checkbox" name="test5" value="Travel Deals-monthly" %%=v(@acts1)=%%/> Travel Deals-monthly
<br><input type="checkbox" name="test5" value="Ski Deals Seasonal" %%=v(@acts2)=%%/> Ski Deals Seasonal
<br><input type="submit" value="submit"/>
</form>
Here I am using lot of If conditions in these lines:
 
 
if @Split1 == "Seasonal travel information and trip ideas"  then
      SET @acts= "checked" 
  endif
  if @Split1 == "Travel Deals-monthly"  then
      SET @acts1= "checked" 
  endif
if @Split1 == "Ski Deals Seasonal"  then
      SET@acts2 = "checked" 
  endif
 if @Split2 == "Seasonal travel information and trip ideas"  then
      SET @acts= "checked" 
  endif
  if @Split2 == "Travel Deals-monthly"  then
      SET @acts1= "checked" 
  endif
if @Split2 == "Ski Deals Seasonal"  then
      SET @acts2= "checked" 
  endif
 if @Split3 == "Seasonal travel information and trip ideas"  then
      SET @acts= "checked" 
  endif
  if @Split3 == "Travel Deals-monthly"  then
      SET @acts1= "checked" 
  endif
  if @Split3 == "Ski Deals Seasonal"  then
      SET @acts2= "checked" 
  endif
 
 
Is it possible to minimize the If conditions using AMPScript code? can anyone please help me?
what is the difference between standard Controller and Custom Controller in accessing the Visual Force Page
Using Http Method Post Method

How to write a Apex class to get through the file in Apex class

I have tried with the Following code

@HttpPost global static String dopost(){
string boundary;
RestRequest req = RestContext.request;
system.debug(req); Blob body = req.requestBody;
system.debug(body);
string body1 =body.toString();
system.debug(body1);
/*String boundary = '----------------------------9woZbkLDjbVEehiu';
string body2 = '--' +boundary + '\nContent-Disposition: form-data; ' + 'name="Elavarasan"; ' + 'filename="' + body1.filename; + '";\nContent-Type: text/plain';
*/ /*Blob body2 = EncodingUtil.base64Decode(body1);
System.debug(body2);*/ //system.debug(body1.filename);
string[] accountDataLines = new String[] {};
accountDataLines = body1.split('\n\n\n');
system.debug(accountDataLines[0]);
//dto df = (dto)json.deserialize(accountDataLines[0],dto.class);
string[] csvFieldNames = accountDataLines[0].split('"name"');
system.debug(csvFieldNames); system.debug(csvFieldNames.size());
/*for (Integer i = 0; i < csvFieldNames.size(); i++) {
system.debug(csvFieldNames.size());
system.debug(csvFieldNames[i]);
*/ string[] csvFieldNames1 = body1.split('"phone"');
system.debug(csvFieldNames1);
account cf = new account();
//cf.Name=csvFieldNames;
//system.debug(cf.Name);
//cf.phone=csvFieldNames1;
//system.debug(cf.phone);
string[] csvFieldNames2 = body1.split('"Website"');
// cf.Website=csvFieldNames2;
//system.debug(cf.Website); return null; }
public class dto {
public string Name{get;set;}
public string phone{get;set;}
public string website{get;set;} }

I am unable to seperate the Blob body ,because it contains Header ,footerValue then how i will get the body of the file Content,can anyone please help for the Answer
@HttpPost
global static String doPost() {
       RestRequest req = RestContext.request;
       RestResponse res = Restcontext.response;

       Blob body = req.requestBody; System.debug('Test:' + body.toString());
       
       
UpdateProfile profiles = (UpdateProfile)System.JSON.deserialize(body.toString(),UpdateProfile.class); System.debug('Parsed Input:' + profiles);
 
if (profiles.UserId == '' || profiles.UserId == Null)  profiles.UserId = UserInfo.getUserId();
return updateProfileDetails(profiles); }

global static String updateProfileDetails(UpdateProfile profiles)
{
try { list < User > users = [Select id, Title, FirstName, LastName, Email, Username, Country, MobilePhone, Fax, Phone, ContactID, AccountID, PG_SecretAnswer__c, PG_SecretQuestion__c, PG_SecretAnswerSalt__c, JE_Password__c, PG_TCAgreed__c, IsActive from User where Id =: profiles.UserID];

if (!users.isEmpty()) {}

else { throw new CustomException(PG_Utils.getException(USER_ERROR, GENERIC_ERROR_TYPE, CustomException__c.getValues('PC0001').Error_Description__c)); //user Not Found Given with another Id means Account Id } }

catch (Exception e)
{ return e.getMessage(); //user Id is like erty or alphabets }

return null; // when?????? }
When this Class Function Return Null Statement,How to write a test Class for Failing Input for Returning Null Statement???
This Class Indicates In PostMan what are the request Body which is Given that is Updated with the particular user with the help of userId, If user Id is Not Given, By Default it Take with the Help of Statement userinfo.getUserId, when this Class Function Return Null Statement,How to Write a test class for Failing Input for Returning Null Statement,Please Anyone Guide Me?