SilverStripe - PhoneNumberField output - silverstripe

I am trying to use PhoneNumberField to get the phone number but it gives the output as an array. How can I get the exact input?
$mobilePhone = PhoneNumberField::create('MobileTelephone', 'Mobile Telephone *');

Assuming you are submitting your form to an action such as public function send($data, $form) {...} then you would retrieve the phone number with PhoneNumberField::joinPhoneNumber($data['MobileTelephone']).
According to the PhoneNumberField API description:
Field for displaying phone numbers. It separates the number, the area code and optionally the country code and extension.
Reading the PhoneNumberField code we can see the field is a grouping of fields for the phone number's Country, Area, Number and Extension. By default only the Number field is used, but it will still return the results as an array.

Related

Ultimate member plugin - Phone and email fields are optional but the user must fill in at least one

How can I create a function that let you show an error if none of the two specific fields ( both optional) are not filled? We want at least one to be filled, otherwise to show an error.

Searching phone number in .NET Core

I'm working on a project where I have to add the functionality of searching for phone numbers using dot net core. on SignUp, we are storing phone numbers in SQL Server using the country code eg: "+923007418819".
So if the user searches the phone number with 03007418819 it's not matching the data stored in the database and returns null.
The main thing I want is that if the user enters the phone number 03007418819 like this, it searches with the last 10 digits.
How can it be done?
First you have to create a computed persistant column with the reversed phone number like this :
ALTER TABLE T_PHONE ADD _PHONE_NUMBER_REVERSE AS REVERSE(PHONE_NUMBER) PERSISTED;
Second you have to create an index for performances searches :
CREATE INDEX X_001 ON T_PHONE (_PHONE_NUMBER_REVERSE);
Last, you have to use a WHERE clause like this one :
WHERE _PHONE_NUMBER_REVERSE LIKE REVERSE('03007418819') + '%'
This is the most efficient way to do that !
You can use SUBSTRING :
SELECT SUBSTRING([your column name], 3, 10) AS phone,
FROM [your table name]
WHERE [your column name] = [search term];
Different approach:
the best way to solve this issue from its roots is to save all users' phone numbers in the database in a specific format e.g. 00[countrycode][rest]
Create a helper that will format any valid phone number the user enters to the format you want when signing up. All phone numbers will be then formatted before being saved in the database. (The database will be then formatted and clean)
When the user tries to sign in, the same helper will first be called and format the number the user entered, and then you can easily search in the database with no magic. With this tiny modification, you can win the database index as well.

Patch function doesn't send items to my sharepoint list ( Power Apps)

please, I have a problem with the Patch function, it shows me no error but it sends nothing to the sharepoint list, here are the columns I have:
Country, Project_Customer, Project_Category, Project_Type, are comboboxes of choice, project_site is a search column, project manager is a person type column, project description and project name are text lines and project amount is a number (currency type) , and project_status is a dropdown.
here is the patch function:
{Country: ComboBoxCOUNTRY.Selected;
Project_Customer: ComboBoxCustomer.Selected;
Project_site: ComboBoxSite.Selected;
Project_Category: ComboBoxCATEGORY.Selected;
Project_Type: ComboBoxPROJECTTYPE.Selected;
Project_Name: Text (TextInputProjectName);
Project_Amount: TextInputProjectAmount;
Project_status: DropdownSTATUS;
Project_manager: ComboBoxmanager;
'Project_Description': Text (TextInputDETAIL)})````
Different SharePoint fields have different requirements for patching.
For a Person field you have to send an object with Claims, Department, DisplayName, Email, Jobtitle and Picture fields, but only the Claims, displayname and email address seem to be required (you may want to experiment with which fields actually need a value, but all of them have to be present). Below is an example from one of my powerapps
AssignedTo: {'#odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims:Concatenate("i:0#.f|membership|",Assignee.UserPrincipalName),
Department:"",
DisplayName:Assignee.DisplayName,
Email:Assignee.Mail,
JobTitle:"",
Picture:""
}
For SharePoint choice fields, you have to send an object with a value property
mychoicefield: {Value: "some value" }
For lookup fields, you have to send an ID and value, where ID is the ID from the lookup list item and Value is the Title
MyLookupField: { ID:1,Value:"Some title"}
Patch doesn't throw an error when you send the wrong information. YOu can capture and output your patch by setting a variable or checking for errors. I typically do both
Set(PatchResults,Patch(datasource,defaults(datasource),{
Title: "Hello"
};
If(Not(IsEmpty(Errors(datasource))),Notify(First(Errors(datasource)).Message,NotificationType.Error))
The above check if the datasource to which you patched has any errors and if there are, creates a message at the top with a red background.

In a PDF, How to auto populate one field using other field text?

I have a 54 pages PDF file. In this PDF, I have some fields like Full Name, the Phone number, etc that repeats more than 10 times. How can do like When I enter Full name one time and all of the remaining full name fields can be filled automatically using Adobe Acrobat?
I hope I asked my question clearly. Thank you for your time and help.
The easiest is, when all properties of the field (font type, size, color, etc.) are the same, to simply copy the field to the other pages.
The field value is a so-called field level property, which will be the same for all instances of the field.
If you want to have only one place where the value can be entered, and the dependent fields should be read-only, you would have to have a different name for the entry field and display fields. In the entry field, you would then add the following line of code in either the Format or onBlur event:
this.getField("myDisplayFields").value = event.value ;
And that should push the value from the entry field to all fields named myDisplayFields.
And that's it…

sequence of error messages for required field in drupal 7

I have a content type which has 4 CCK fields.
Field name are :
field_device_data_card_id
field_device_model
field_device_type
field_device_id
These fields are in their respective sequence.
all fields are marked as mandatory. when i click submit button without filling any data in required fields, it generate error messages for mandatory fields but the sequence of error messages are not proper.
it is displayed in following sequence ->
Device Data Card ID field is required.
Device ID field is required.
Device Model field is required.
Please select a device type.
while it should be like ->
Device Data Card ID field is required.
Device Model field is required.
Please select a device type.
Device ID field is required.
Please provide me a solution so that i can sequence the error messages.
Thanks
.. add your custom validator via hook_form_alter and:
function form_name_validate($form, &$form_state) {
$tmp_msg = drupal_get_messages('error');
// change order or modify on your own of $tmp_msg
drupal_set_message($tmp_msg,'error');
}

Resources