I am trying to add a validation into an existing Google Form. I was already able to identify the item ID of the field I want to add a validation. I am just doing first the very basic requireTextContainsPattern in my text validation. I tried to follow https://developers.google.com/apps-script/reference/forms/text-validation
function validationTest() {
var form = FormApp.openById('formID');
var item = form.getItemById(itemID);
var textValidation = FormApp.createTextValidation()
.setHelpText("Enter email address")
.requireTextContainsPattern("info#example.com")
.build();
item.setValidation(textValidation);
When I debug my code, I am getting
TypeError: item.setValidation is not a function
My question is: 1) How do I get this textvalidation into my the existing field in Google Form? 2) Is the error I am getting related to my question no. 1? But primarily, I wanted to resolve no. 1.
Thanks in advance!
Form.getItemById(id) returns Item. You need to change the reference from Item to TextItem. To do so you may use the method asTextItem() (see reference)
function validationTest() {
var item = form.getItemById(itemID).asTextItem();
// [...]
}
Note that this will throw an error if itemID is not an ID of a text item.
References
Interface Item (Google Apps Script)
Class TextItem (Google Apps Script)
Related
i need to create a filtered search based on different paramnters chosen by a user. So, for example, my app is a property app. I want them to be able to define the county, town, max,min bedrooms ect from a dropdown list and press search, and this returns all the properties that match the criteria.
How do I go about doing this? I can't find any tutorials online, but maybe I'm not phrasing it right.
Here is an image of what I'm after from a UI point of view.
https://imgur.com/a/YEEqt
The following is an easy to go solution considering your experience.
Create a new controller or a method in an existing one.
First create a simple form (method GET) in blade that will return predefined values from simple hidden fields
Create a new GET route in which the form must be submitted and link it to the controller method that you created
In your controller method get the submitted form data from your request, make the correct queries and return the blade template file that contains the form with the results
Modify blade template to show results
Finally replace the hidden fields with selects drop-downs and modify your controller in order to populate them
You can make the form submission process and the select drop-down fields population asynchronous but based on your experience with Laravel it should be hard. Following the steps above will do your job.
Always take a look to the official documentation. You will ge a lot of help from there.
You can try like this for filter options in your controller
public function filter(Request $request, Property $property)
{
$property = $property->newQuery();
// Search for a property based on country
if ($request->has('country')) {
return $property->where('country', $request->input('country'));
}
// Search for a property based on their area.
if ($request->has('areas')) {
return $property->where('areas', $request->input('areas'));
}
// Search for a property based on max_price
if ($request->has('max_price')) {
return $property->where('price','<=', $request->input('max_price'));
}
// Continue for all of the filters.
return $property->get();
}
For more info refer the link
I have a member in my project called Customer. I need to validate PasswordField.
I created a function in my page containing the PasswordField as below
function getValidator() {
$data = $this->loadData();
if (#$data['Password']->minLength(7)) {
return $this->validationError('Password', 'Password field should contain minimum 7 charactors', 'bad');
}
}
This does not give any result. How do I get this working?
Remove that ugly # from your code and watch that beautiful error message. Error supression is a real bad practice, you should avoid that
There is already a class PasswordValidator which is used by the Member object and can check the minimum length of a password. (See API Docs for PasswordValdiator)
If you show us more code I can try to help you implementing it right.
Is your Customer object a subclass of Member? Where is the password changed? What FormField is used for Password? There is also a ConfirmedPasswordField showing two masked fields for matching passwords where you can set a minlength.
So, assuming you save your password in a field called Password you could set up the field e.g.
$passwordField = ConfirmedPasswordField('Password', 'Choose a password');
$passwordField->minLength = 7; //there is no setter method for that right now
Then add $passwordField to your FieldList e.g using
$fields->push($passwordField);
This code works to get content from the broker for all components whos name begins with "MC":
Criteria c1 = new ItemTitleCriteria("MC%", Criteria.Like);
//Create query
Query myQuery = new Query(c1);
String[] itemURIs = myQuery.ExecuteQuery();
ComponentPresentationAssembler cpAssembler = new ComponentPresentationAssembler();
foreach (string componentUri in itemURIs)
{
String content = cpAssembler.GetContent(componentUri, componentTemplateUri);
}
However, I am struggling to find in the api where I can actually access the names (or titles) of each component returned.
I'm not sure if the broker API has such capabilities to retrieve those attributes. You may probably need to use another library to retrieve information from the CMS.
But to answer your question, one way to get the title if to publish it to the brokerDB as part of the content (cpAssembler.GetContent()). Just make sure that you render Component.Title in the component template. Once it's in the DB, you can parse it.
Sample content:
<model id="modelId" title="componentTitle" />
Note: Tridion has its own StackExchange site now, you may get more interaction there. https://tridion.stackexchange.com/
I would like to know the difference between
$("#uploadedFile").val(e.files[0].name);
var model = $("#blueprint_listview").data("kendoListView").dataSource.get(0);
model.set("filename", $("#uploadedFile").val());
And
$("#uploadedFile").val(e.files[0].name);
var model = $("#blueprint_listview").data("kendoListView").dataSource._data[0];
model.set("filename", $("#uploadedFile").val());
I am having an editable listview with a upload.
And the above code is written on the success event on the kendo upload.
The second code works fine for insert and update.
However, the first code works fine for insert, but for update it is showing an error which says - "The model is not defined"
I was wondering what could be the reason?
As stated in the documentation, get retrieves a record with the corresponding id. This way, when a new record is inserted it seems that it has the default id of 0, that's why get(0) === _data[0] but when you are updating the listview, a "real" id (>=1) is given to your new line and there is no longer an item with id=0, so model is then null.
On the other side, the internal method _data is an array with all the lines of your list view put in the order of their position in the listview. But if you want to access to this property, the equivalent "public" method is at :
$("#blueprint_listview").data("kendoListView").dataSource._data[0] ===
$("#blueprint_listview").data("kendoListView").dataSource.at(0); // allways true
Imagine, you want to add an email to a case. The email form opens and the "To" field is auto-populated with the case's customer account.
I want to change the behavior in order to auto-populate the content of "To" with a custom property of the related case.
My first approach was to register a JavaScript for the OnLoad event of the form and let the script change the field. That would work, but I am wondering if there is a smarter way to achieve this. There is already some logic, which fills the "To" field. Is it possible to configure this existing feature?
Any hints are appreciated.
I do not believe that this specific scenario can be done more effectively than how you've already worked it out. I would've suggested looking at the data mappings (left-nav item when you pop open the relationship in the entity's customizations, same concept as discussed in this Dynamics CRM 4.0 article http://www.dynamicscare.com/blog/index.php/modifying-mapping-behavior-between-parent-child-records-in-microsoft-dynamics-crm/), but it does not appear to be applicable to this relationship.
This might help you:
DataService.EntityReference toEntityRef = new DataService.EntityReference();
toEntityRef.LogicalName = "contact";
toEntityRef.Id = Guid.Parse(to_id);
Entity toParty = new Entity();
toParty["partyid"] = toEntityRef;
toParty.LogicalName = "activityparty";
Entity emailEntity = new Entity();
emailEntity.LogicalName = "email";
EntityCollection toCollection = new EntityCollection();
toCollection.Entities = new ObservableCollection<Entity>();
toCollection.Entities.Add(toParty);
emailEntity["to"] = toCollection;
IOrganizationService soapService = ServerUtility.GetSoapService();
IAsyncResult res = soapService.BeginCreate(emailEntity, OnCreateComplete, soapService);
Call Back method:
private void OnCreateComplete(IAsyncResult result)
{
Guid emailId = (IOrganizationService)result.AsyncState).EndCreate(result);
}
Another approach would be to replace the Add Email buttons in the ribbon in order to call a custom JavaScript function. This function could open the mail window with window.open and initialize the To: field by setting the extraqs parameter to configure an ActivityParty for the email about to create. This can be done by setting:
partyid to the id of an allowed entity's instance
partyname to the name of the entity instance
partytype to 2 (for the recipent field, see here for details)
But the extraqs parameter is limited: You can set only one receiver and no other field (from, cc, bcc, ...). Moreover, replacing the buttons would bypass built-in functionality, which may change in future versions,
So I prefer the handling of the OnLoad event of the form.