Quantcast
Channel: SharePoint JavaScripts » All Posts
Viewing all 4642 articles
Browse latest View live

Reply To: Bug in FormConfig system for multiple configurations

$
0
0

Hi,
It seems I have a bug in the Restore functionality that fails to apply the query string to the cloned item. I’ll look into it, but as a workaround you can open the list “SPJS-DynamicFormsForSharePoint”, locate the newly created item and manually append ?FormType=auto to the Title.

Alexander


Reply To: Pull user info from a people picker

$
0
0

Andrew – I work with Brett who responded above and she can’t figure out where I am screwing up. This WAS working a few days ago and I don’t know what kinked it up.

I have a people picker that is only entered on the NewForm and I want to pull out LastName & FirstName into their own fields. I cannot get LastName FirstName fields to display in the DispForm. They display fine on the EditForm.

Do I need code on all three forms or just one?

This is the code I am using on the NewForm and EditForm

function PopulateLastFirst ()
 {
//Pull in Last Name and First Name from Employee field.
$.each(spjs.utility.getFieldValue({"fin":"Employee","key":"loginName"}),function(i,login){
    var ppData = spjs.utility.userInfo(login);
    console.log(ppData);
    // User profile is not available in SP Foundation
    var userProfile = spjs.utility.userProfile(login);
    console.log(userProfile);
    setFieldValue("Last_x0020_Name",userProfile.LastName); 
    setFieldValue("First_x0020_Name",userProfile.FirstName); 
});
}

This is the code I have on the DispForm

function PopulateLastFirst ()
{
$.each(spjs.dffs.beforeProperties["Employee"],function(i,userId){
var ppData = spjs.utility.userInfo(userId);
console.log(ppData);
// User profile is not available in SP Foundation
var userProfile = spjs.utility.userProfile(ppData.Name);
console.log(userProfile);
    setFieldValue("Last_x0020_Name",userProfile.LastName); 
    setFieldValue("First_x0020_Name",userProfile.FirstName); 
});
}

I even tried this on advice from Brett… on the DispForm

function PopulateLastFirst ()
{
$.each(spjs.dffs.beforeProperties["Employee"],function(i,userId){
var ppData = spjs.utility.userInfo(userId);
console.log(ppData);
// User profile is not available in SP Foundation
var userProfile = spjs.utility.userProfile(ppData.Name);
console.log(userProfile);

});
}

Any help you could give would be much appreciated.

Reply To: Pull user info from a people picker

$
0
0

I am an idiot… I got it to work

Reply To: DFFS Built-in Function Reference – seeking volunteers

$
0
0

Changing tab colors

/* Style base tab */
li.tabBase a{
background-color:gray!important;
padding:0 2px!important;
}
li.tabBase span{
color:black!important;
}
/* Style selected tab */
li.tabSelected a{
background-color:green!important;
padding:2px!important;
}
li.tabSelected a span{
color:yellow!important;
}

from http://spjsblog.com/forums/topic/css-style-of-selected-tab/

Reply To: Pull user info from a people picker

$
0
0

I’m glad you figured it out!

Best regards,
Alexander

Using code to replace rules

$
0
0

Alex, I’m experimenting with using custom JS functions instead of rules for our very complex forms. I’m wondering if I can do any of the following using already existing objects or functions rather than create my own functions:
1. Change the selectedTab
2. save an array of all the hidden fields on the form to a field on the list, and an array of all the required fields on the form to a field on the list (so I can use those arrays when the form opens on the next step in the process without having to preserve all the rules from the previous step).

Reply To: DFFS Built-in Function Reference – seeking volunteers

$
0
0

spjs.dffs.triggerSave(); saves record

Reply To: Using code to replace rules

$
0
0

Hi,
To change the tab you can use this snippet:

spjs.dffs.toggleSelectedTab(index);

The index is the tab index or the found in the Tab unique ID.

To save an array of all hidden fields you can use this snippet:

var arrOfHiddenFields = [];
jQuery.each(spjs.dffs.data.hiddenColTrackerObj,function(fin,o){
	if(o.hidden){
		arrOfHiddenFields.push(fin);
    }
});
setFieldValue("NameOfFieldToWriteTo",arrOfHiddenFilds.join(","));

And to save an array of all required fields you can use this snippet:

setFieldValue("NameOfFieldsToWriteTo",spjs.dffs.data.requiredFields);

Please note that when using custom code to “drive the form logic” you may get some strange results when for example you toggle a tab and the internal functions in DFFS doesn’t know what fields are visible etc.

Alexander


Reply To: Using code to replace rules

$
0
0

Thanks for the prompt reply, Alex. I’m trying to figure out how to ‘reconstitute’ the hidden fields the next time my form opens from the list column where I saved the array of hidden fields (my column is name ‘luHiddenFields’). So far, I’ve got this much:

var arrHiddenFields = getFieldValue(“luHiddenFields”).split(“,”);
for (var i=0; i < arrHiddenFields.length;i++){
var fieldId = “dffs_” + arrHiddenFields[i];
jQuery(fieldId).hide();
}
This successfully hides the fields. However, I think I also need to update the spjs.dffs.data.hiddenColTrackerObj object in order to be able to capture the list of hidden fields when I save the current tab (in case more fields have been hidden). How would I do that? Or, should I just append the new hidden fields to my array of hidden fields stored in my luHiddenFields column?

Reply To: Using code to replace rules

$
0
0

Are you combining this custom code with the use of rules to show or hide the fields? – if not, you can make it easier, but if you do you can just add these lines in your for-loop:

spjs.dffs.data.hiddenColTrackerOb[fieldId].hidden = true;
spjs.dffs.data.hiddenColTrackerOb[fieldId].hiddenBy.rule = true;

Alexander

Capture User Input in Popup

$
0
0

Hi Alex,

I am new to the DFFS. I have a requirement to create a button Onclick function, which will open a popup with people picker control, where user will select the people. I have to capture the user input people value and append that value in existing people picker column. I tried to look similar requirement in forum but couldn’t find. I am checking if you have existing object/function to handle this scenario.

Attachment Required

$
0
0

Hi Alex,
I am facing one issue while applying rules. Attachment column is conditionally required. In initial rule, I am making Attachment column as conditionally required and reversing of rule is applied. In another rule on different condition I am making again attachment column as conditionally required and reversing of rule is applied. Trigger condition in both the rules are different columns and I want reversing to apply as there are other columns as well as hidden/required based on the trigger condition.

So if Rule 1 is true and attachment is marked required and later on the same form/tab If rule 2 is false then it makes attachment as optional. Please suggest how to handle this scenario as I can’t add more than one attachment column.

Reply To: Capture User Input in Popup

$
0
0

Hi,
Start by adding this to a HTML section in one of your tabs:

<input type="button" onclick="popUpPeoplePickerExample()" value="Show People picker">

Then add this to your Custom JS:

function popUpPeoplePickerExample(){
    spjs.dffs.alert({
        "title":"People picker example",
        "msg":"<div id='customPeoplePicker' onkeydown='event.stopPropagation()' style='height:22px'></div>",
        "ok":function(){
            var pp = SPClientPeoplePicker.SPClientPeoplePickerDict.customPeoplePicker_TopSpan, users = pp.GetAllUserInfo(), arr;
            // Get current PP values
            arr = spjs.utility.getFieldValue({"fin":"Requester","key":"loginName"});
            jQuery.each(users,function(i,o){
                arr.push(o.Key);
            });
            setFieldValue("Requester",arr);
        },
        "cancel":function(){
            // Close dialog
        }
    });
    var schema = {};
    schema.PrincipalAccountType = 'User,DL,SecGroup,SPGroup';
    schema.SearchPrincipalSource = 15;
    schema.ResolvePrincipalSource = 15;
    schema.AllowMultipleValues = true;
    schema.MaximumEntitySuggestions = 50;
    schema.Width = '350px';
    schema.Height = '55px';
    this.SPClientPeoplePicker_InitStandaloneControlWrapper("customPeoplePicker", null, schema);
}

You must change “Requester” in the above snippet with the name of the People picker you want to update with the values.

Let me know how this works out.

Alexander

Reply To: Attachment Required

$
0
0

I’m not 100% sure I understand, but look at the “Linked rules and functions” setting in the rule trigger. Maybe you can check the status of the other rule and only apply the the second rule if the first rule is “true”.

Alexander

Reply To: DFFS Built-in Function Reference – seeking volunteers

$
0
0

Programmatically set required field:

Required fields are stored in this array:
spjs.dffs.data.requiredFields

and you can push in new fields like this
// Push new required field into array
spjs.dffs.data.requiredFields.push(“YourFieldName”);
// Show star on all required fields
spjs.dffs.starRequired();

If you need to remove a field from the array, you can use this function:
spjs.dffs.data.requiredFields = spjs.dffs.removeFromArr(spjs.dffs.data.requiredFields,”YourFieldName”);

From: http://spjsblog.com/forums/topic/programmatically-set-required-field/
See also: http://spjsblog.com/forums/topic/programmatically-set-field-to-required-based-on-multiple-inputs/


Reply To: Programmatically Set Required Field

$
0
0

Alex;

1. It looks like spjs.dffs.flag_Mandatory(‘FieldInternalName’) will set the field to required AND show the red star on that field. Is that correct?
2. Is there an internal dffs function that does the opposite? (that is, sets the field to optional and removes the red star on that field? Or a function just to remove the red start, if we use spjs.dffs.data.requiredFields = spjs.dffs.removeFromArr(spjs.dffs.data.requiredFields,”YourFieldName”) to make the field optional again?

Required Fields

$
0
0

I recently upgraded DFFS to 4.4.3.42 and now I can no longer hide a list driven required field until the given selections are made. For example, one combination of selections enables the required field to be auto-populated (reducing keying errors), but another combination of selections should require the field to be updated by the user. I want to hide the required field until the selections are made and display the field either as editable if the user must complete it or read only if it is auto-populated.

Is there a way to hide the required fields until such time as the user must enter information?

Reply To: Required Fields

$
0
0

Hi,
I’m not sure which version you used prior to the update, but this has been “by design” for quite some time to ensure you cannot have a required fields hidden without it being filled in properly – because this would prevent you from saving the form without the possibility to supply a value for this field.

The easy workaround would be to set the field as optional in the list settings and use DFFS rules to set it as required.

Alexander

Reply To: E-Mail and Print

$
0
0

Hi Alexander,

many thanks for this reply. for the same topic i am looking into the possibility to send emails to adistribution group specified?

is this possible?

thanks

Reply To: E-Mail and Print

$
0
0

It depends on how your exchange server is configured – if the sender of the email (the account in the from field when you receive the email) doesn’t have necessary rights on this distribution list you won’t be able to send to it.

Alexander

Viewing all 4642 articles
Browse latest View live