function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Robert Wambold 10Robert Wambold 10 

Is it possible to use a Forward Slash ("\") in a Text field?

Hi All,

I have a user request where the User would like a Path to a Windows Directory created from Salesforce data.

I originally tried using Apex, but APex did not like the Forward Slash. So I thought I would create Text Field on the Object with Forward Slash as the default value, but this was not allowed.

Any suggestions o should I just tell the user no. I hate saying no.

Goal is to create MyOpsPath = '\\MyFiles\MyFolder\';

Best Answer chosen by Robert Wambold 10
PRAKASH JADA 13PRAKASH JADA 13
Hi,


It is possible with apex code you can try like this.


Trigger code:
----------------------------

trigger AccountTrigger on Account (before insert, before update) {
    if(Trigger.isBefore) {
        if(Trigger.isInsert) {
           AccountHandler.onBeforeSave(Trigger.New); 
        }
        if(Trigger.isUpdate) {
            AccountHandler.onBeforeSave(Trigger.New);
        }
    }
}

Apex class:
-------------------
public with sharing class AccountHandler {
    public static void onBeforeSave(List<Account> accountList) {
        String appedingValue = '\\';
        for(Account acc : accountList) {
            acc.Name = appedingValue + acc.Name;
        }
    }
}

I hope this helps.

All Answers

PRAKASH JADA 13PRAKASH JADA 13
Hi,


It is possible with apex code you can try like this.


Trigger code:
----------------------------

trigger AccountTrigger on Account (before insert, before update) {
    if(Trigger.isBefore) {
        if(Trigger.isInsert) {
           AccountHandler.onBeforeSave(Trigger.New); 
        }
        if(Trigger.isUpdate) {
            AccountHandler.onBeforeSave(Trigger.New);
        }
    }
}

Apex class:
-------------------
public with sharing class AccountHandler {
    public static void onBeforeSave(List<Account> accountList) {
        String appedingValue = '\\';
        for(Account acc : accountList) {
            acc.Name = appedingValue + acc.Name;
        }
    }
}

I hope this helps.
This was selected as the best answer
Robert Wambold 10Robert Wambold 10

Prakash,

Thank you for your help. I am now able to create the desired path,

MyOpsPath__c=(Slash2+Slash2+PthLit1+Slash2+'sqman'+Slash2+PthLit2+Slash2+Ctgry+Slash2+LstAccts[0].Site+Slash2);

Robert

 

PRAKASH JADA 13PRAKASH JADA 13
Thank you.