How to set required fields in Power Apps - powerbi

I have various Text input fields in my blank page of Power Apps, I want to implement a functionality where the user is unable to submit the form if any of the fields are kept blank. I saw various sources and used this on my submit BUTTON. Selecting DisplayMode and writing this code there:
If(!IsBlank(TLow.Text || !IsBlank( THigh.Text ||
!IsBlank(TTime.Text || !IsBlank( AlertSeverity.Text ||
!IsBlank(RTime.Text || !IsBlank(An.Text)))))),
DisplayMode.Disabled,DisplayMode.Edit)
However I am unable to achieve what I want ( i.e Submit button should only be enabled if all the fields are filled )
Where am I going wrong?

I was doing a very small error , I was not converting "number" to "Text" value. This is the code I implemented and achieved my functionality
If(!IsBlank(AlertDescription.Text) && !IsBlank(AlertSeverity.Text)
&& !IsBlank(Value(ThresholdHigh.Text))
&& !IsBlank(Value(ThresholdLow.Text))
&& !IsBlank(Value(ThresholdTime.Text))
&& !IsBlank(Value(ResolutionTime.Text)),DisplayMode.Edit,DisplayMode.Disabled)

Related

I m inserting my data uthrough page item using request process it gives an error fetch more then one row please give me a solution

var a = $v('P1995_LUMBER');
if ((a = '1')) {
apex.submit({
request: "CREATE",
set: {
LUMBER: "P1995_LUMBER",
LST_NME: "P1995_LST_NME",
FST_NME: "P1995_FST_NME",
},
});
} else if (a != '1') {
apex.submit({
request: "Update",
set: {
LUMBER: "P1995_LUMBER",
LST_NME: "P1995_LST_NME",
FST_NME: "P1995_FST_NME",
},
});
} else {
alert("bang bang");
}
Couple of things:
JavaScript's equality check is either == or === (more details here). (a = '1') assign '1' to the variable.
It seems like you're not using the apex.submit process correctly. Typically, you would set the item's value
e.g.:
apex.page.submit({
request: "SAVE",
set: {
"P1_DEPTNO": 10,
"P1_EMPNO": 5433
}
} );
Although, by looking at your JavaScript code, I would say you don't even need to use JavaScript.
Whenever you submit a page, all items on it are automatically sent to the server-side. You can then reference them using bind variables. You could then simply have two process, one for the Create and one for the Update, each having the corresponding insert/update statement using the different items on your page.
Usually what you will see is a page with two buttons for Create/Edit. They will have a server-side condition so that only the correct one is displayed.
Try creating a Form type page (form with report) using the wizard, and you'll see how everything is done.
Without seeing the page and the code you're using it's hard to tell what your issue really is, more details would be required.
That code does not have any sql in it so it is impossible to diagnose why you are encountering a TOO_MANY_ROWS exception. Run the page in debug mode and check the debug data - it should show you what statement is throwing the exception. If you need more help, post a proper reproducible case, not a single snipped of code without any context.

opencart 3.0.2.0 remove model required restriction

How can i remove the "model required" from the model field in admin product page in opencart v 3.0.2.0, and make it an optional field like the rest of the fields in the data tab?
model required screenshot
its not correct to not insert model no, still i show you.
admin\controller\catalog\product.php
go to line no 1193 - approximate
find this code in protected function validateForm() {
if ((utf8_strlen($this->request->post['model']) < 1) || (utf8_strlen($this->request->post['model']) > 64)) {
$this->error['model'] = $this->language->get('error_model');
}
after comment
/*if ((utf8_strlen($this->request->post['model']) < 1) || (utf8_strlen($this->request->post['model']) > 64)) {
$this->error['model'] = $this->language->get('error_model');
} */
you have to comment this code or you can remove it, but i think you need this code in future so do only comment this code don't remove it.

How to add form alter hook in drupal 8

I am very much new to drupal 8, I am trying to alter a form under custom content type "Question". The form has an id "node-question-form".
I have setup a module and trying to add hook_FORM_ID_alter() but its never getting called. Even the simplest hook is not working. eg:
function constellator_form_alter(&$form, &$form_state, $form_id){
echo "alter the form"; exit;
}
where 'constellator' is the module name.
I have been stuck with since morning and nothing is working for me, Any help will be greatly appriciated.
Cheers
hook_form_alter() and hook_FORM_ID_alter() are called while a form is being created and before displaying it on the screen.
These functions are written in the .module file.
Always clear the cache after writing any hook function. This makes Drupal understand that such a function has been declared.
Use drush cr if using drush version 8 else click on Manage->Drupal 8 logo->Flush all Caches to clear the caches.
Now you can check if the function is being called or not.
The best way to check that is to install the Devel module, enable it. Along with Devel, Kint is installed. Enable Kint too from the Admin UI.
After doing that,you can check whether the hook is being called or not in the following way:
function constellator_form_alter(&$form, &$form_state, $form_id){
kint($form);
}
This will print all the form variables for all forms in the page.
If you want to target a particular form in the page, for eg. you form, node-question-form, type:
function node_question_form_form_alter(&$form, &$form_state, $form_id){
kint($form);
}
Using echo, the way you did, you can confirm whether the function is being called or not, without any hassle, by viewing the Source Code for the page and then searching for the text that you have echoed, using some search option of browser, like, Ctrl+f in case of Google Chrome.
If you want to change sorting options and/or direction (ASC / DESC), you can use this example (tested with Drupal 9).
Here I force the sorting direction according to the "sort by option" set by the user in an exposed filter. (if the user want to sort by relevance, we set the order to ASC, if the user want to sort by date, we set the order to DESC to have the latest content first).
/**
* Force sorting direction for search by date
*
*/
function MYTHEME_form_alter(&$form, &$form_state, $form_id)
{
if (!$form_id == 'views_exposed_form"' || !$form['#id'] == 'views-exposed-form-search-custom-page-1') {
return;
}
$user_input = $form_state->getUserInput();
if (empty($user_input['sort_by'])) {
return;
}
if ($user_input['sort_by'] == 'relevance') {
$user_input['sort_order'] = 'ASC';
} elseif ($user_input['sort_by'] == 'created') {
$user_input['sort_order'] = 'DESC';
}
$form_state->setUserInput($user_input);
}
Note that "views-exposed-form-search-custom-page-1" is the id of my form,
"relevance" and "created" are the sort field identifier set in drupal admin.
function hook_form_alter(&$form, \Drupal\Core\Form\FormStateInterface &$form_state, $form_id) {
echo 'inside form alter';
}

Sitecore gender personalization

I added personalization rule in my Sitecore site - "Where the gender of the current contact is Male", but I can't figure out how to set "Visitors settings" to test it.
I'll be very grateful if someone can help me with this.
Thanks in advance!
The only Gender condition I found in default Sitecore 8 installation is the one coming from Social module (that is now built-in) located at /sitecore/system/Settings/Rules/Definitions/Macros/Social/Gender in Sitecore tree. Looking up its code I see the following code:
protected override bool Execute(T ruleContext)
{
if (!AnalyticsSettings.Enabled || Tracker.Current == null || Tracker.Current.Contact == null)
return false;
return string.Equals(this.GenderValue, ((IGenderConditionManager) ResolutionExtensions.Get<IGenderConditionManager>((IResolutionRoot) ExecutingContext.Current.IoC, new IParameter[0])).GetGender(GuidExtensions.GetIdentifier(Tracker.Current.Contact.ContactId)).ToString(), StringComparison.OrdinalIgnoreCase);
}
From the code above we can see that to make Gender condition work, you should have analytics and tracking up and running. So if you have that enabled - ensure all settings are correct and it works indeed.
User membership provider does not have gender settings by itself; so the rule condition above can take it only from tracking.

Sitecore: Find the value of a field for a selected Item

I'm trying to create some custom code inside my Sub Layout.
I have to build a newsletter, the newsletter can be composed on a number of article.
An article can be composed by a title / Sub title / Header and image.
Can be, because the Sub title or the image are not mandatory.
To avoid any empty space / missing image in the newsletter email, I would like to create a specific HTML based on the content.
If there is no image, don't show the Image control, if there is no Sub title, don't show the Sub Title control;
To do that, I'm using the following code which is not working :(
Sitecore.Data.Database master = Sitecore.Configuration.Factory.GetDatabase("master");
Sitecore.Data.Items.Item home = master.GetItem("/sitecore/content/Home");
if(home != null && home.Fields != null)
{
string name = home.Fields["Image"].Name; -> Which Fields["Image"] returns null.
}
Is there another way to retreive the field of the selected article ? As my code is not working at all, I don't understand how to retreive the Field value of my selected Item.
Thank you.
In your example, home.Fields is just checking to make sure that the Fields collection exists. You aren't checking if there is a value in the Image field before trying to extract the name.
You probably need something like this:
if(home != null && home.Fields != null && home.Fields["Image"] != null)
{
string name = home.Fields["Image"].Name;
}
Per your comments, it seems to be you are actually trying to pull the image field from the datasource of your component. If you want to conditionally check for the image field before doing something in that case, there are a lot of possible null exceptions that I would want to handle. The code should probably be something like:
var parent = ((Sitecore.Web.UI.WebControl)Parent);
if(parent != null){
Item dataSourceItem = string.IsNullOrWhiteSpace(parent.DataSource) ? null : Sitecore.Context.Database.GetItem(parent.DataSource);
if(dataSourceItem != null && dataSourceItem.Fields != null && dataSourceItem.Fields["Image"]!=null){
string name=dataSourceItem.Fields["Image"].Name;
}
}
Here is one simple way :
Sitecore.Context.Item.Fields["You field name"]